ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/SynchronousQueue.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/SynchronousQueue.java (file contents):
Revision 1.89 by jsr166, Wed Jan 2 06:29:00 2013 UTC vs.
Revision 1.90 by jsr166, Wed Jan 16 01:59:48 2013 UTC

# Line 15 | Line 15 | import java.util.*;
15   * operation must wait for a corresponding remove operation by another
16   * thread, and vice versa.  A synchronous queue does not have any
17   * internal capacity, not even a capacity of one.  You cannot
18 < * <tt>peek</tt> at a synchronous queue because an element is only
18 > * {@code peek} at a synchronous queue because an element is only
19   * present when you try to remove it; you cannot insert an element
20   * (using any method) unless another thread is trying to remove it;
21   * you cannot iterate as there is nothing to iterate.  The
22   * <em>head</em> of the queue is the element that the first queued
23   * inserting thread is trying to add to the queue; if there is no such
24   * queued thread then no element is available for removal and
25 < * <tt>poll()</tt> will return <tt>null</tt>.  For purposes of other
26 < * <tt>Collection</tt> methods (for example <tt>contains</tt>), a
27 < * <tt>SynchronousQueue</tt> acts as an empty collection.  This queue
28 < * does not permit <tt>null</tt> elements.
25 > * {@code poll()} will return {@code null}.  For purposes of other
26 > * {@code Collection} methods (for example {@code contains}), a
27 > * {@code SynchronousQueue} acts as an empty collection.  This queue
28 > * does not permit {@code null} elements.
29   *
30   * <p>Synchronous queues are similar to rendezvous channels used in
31   * CSP and Ada. They are well suited for handoff designs, in which an
# Line 36 | Line 36 | import java.util.*;
36   * <p>This class supports an optional fairness policy for ordering
37   * waiting producer and consumer threads.  By default, this ordering
38   * is not guaranteed. However, a queue constructed with fairness set
39 < * to <tt>true</tt> grants threads access in FIFO order.
39 > * to {@code true} grants threads access in FIFO order.
40   *
41   * <p>This class and its iterator implement all of the
42   * <em>optional</em> methods of the {@link Collection} and {@link
# Line 818 | Line 818 | public class SynchronousQueue<E> extends
818      private transient volatile Transferer<E> transferer;
819  
820      /**
821 <     * Creates a <tt>SynchronousQueue</tt> with nonfair access policy.
821 >     * Creates a {@code SynchronousQueue} with nonfair access policy.
822       */
823      public SynchronousQueue() {
824          this(false);
825      }
826  
827      /**
828 <     * Creates a <tt>SynchronousQueue</tt> with the specified fairness policy.
828 >     * Creates a {@code SynchronousQueue} with the specified fairness policy.
829       *
830       * @param fair if true, waiting threads contend in FIFO order for
831       *        access; otherwise the order is unspecified.
# Line 853 | Line 853 | public class SynchronousQueue<E> extends
853       * Inserts the specified element into this queue, waiting if necessary
854       * up to the specified wait time for another thread to receive it.
855       *
856 <     * @return <tt>true</tt> if successful, or <tt>false</tt> if the
856 >     * @return {@code true} if successful, or {@code false} if the
857       *         specified waiting time elapses before a consumer appears.
858       * @throws InterruptedException {@inheritDoc}
859       * @throws NullPointerException {@inheritDoc}
# Line 873 | Line 873 | public class SynchronousQueue<E> extends
873       * waiting to receive it.
874       *
875       * @param e the element to add
876 <     * @return <tt>true</tt> if the element was added to this queue, else
877 <     *         <tt>false</tt>
876 >     * @return {@code true} if the element was added to this queue, else
877 >     *         {@code false}
878       * @throws NullPointerException if the specified element is null
879       */
880      public boolean offer(E e) {
# Line 902 | Line 902 | public class SynchronousQueue<E> extends
902       * if necessary up to the specified wait time, for another thread
903       * to insert it.
904       *
905 <     * @return the head of this queue, or <tt>null</tt> if the
905 >     * @return the head of this queue, or {@code null} if the
906       *         specified waiting time elapses before an element is present.
907       * @throws InterruptedException {@inheritDoc}
908       */
# Line 917 | Line 917 | public class SynchronousQueue<E> extends
917       * Retrieves and removes the head of this queue, if another thread
918       * is currently making an element available.
919       *
920 <     * @return the head of this queue, or <tt>null</tt> if no
920 >     * @return the head of this queue, or {@code null} if no
921       *         element is available.
922       */
923      public E poll() {
# Line 925 | Line 925 | public class SynchronousQueue<E> extends
925      }
926  
927      /**
928 <     * Always returns <tt>true</tt>.
929 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
928 >     * Always returns {@code true}.
929 >     * A {@code SynchronousQueue} has no internal capacity.
930       *
931 <     * @return <tt>true</tt>
931 >     * @return {@code true}
932       */
933      public boolean isEmpty() {
934          return true;
# Line 936 | Line 936 | public class SynchronousQueue<E> extends
936  
937      /**
938       * Always returns zero.
939 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
939 >     * A {@code SynchronousQueue} has no internal capacity.
940       *
941       * @return zero
942       */
# Line 946 | Line 946 | public class SynchronousQueue<E> extends
946  
947      /**
948       * Always returns zero.
949 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
949 >     * A {@code SynchronousQueue} has no internal capacity.
950       *
951       * @return zero
952       */
# Line 956 | Line 956 | public class SynchronousQueue<E> extends
956  
957      /**
958       * Does nothing.
959 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
959 >     * A {@code SynchronousQueue} has no internal capacity.
960       */
961      public void clear() {
962      }
963  
964      /**
965 <     * Always returns <tt>false</tt>.
966 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
965 >     * Always returns {@code false}.
966 >     * A {@code SynchronousQueue} has no internal capacity.
967       *
968       * @param o the element
969 <     * @return <tt>false</tt>
969 >     * @return {@code false}
970       */
971      public boolean contains(Object o) {
972          return false;
973      }
974  
975      /**
976 <     * Always returns <tt>false</tt>.
977 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
976 >     * Always returns {@code false}.
977 >     * A {@code SynchronousQueue} has no internal capacity.
978       *
979       * @param o the element to remove
980 <     * @return <tt>false</tt>
980 >     * @return {@code false}
981       */
982      public boolean remove(Object o) {
983          return false;
984      }
985  
986      /**
987 <     * Returns <tt>false</tt> unless the given collection is empty.
988 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
987 >     * Returns {@code false} unless the given collection is empty.
988 >     * A {@code SynchronousQueue} has no internal capacity.
989       *
990       * @param c the collection
991 <     * @return <tt>false</tt> unless given collection is empty
991 >     * @return {@code false} unless given collection is empty
992       */
993      public boolean containsAll(Collection<?> c) {
994          return c.isEmpty();
995      }
996  
997      /**
998 <     * Always returns <tt>false</tt>.
999 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
998 >     * Always returns {@code false}.
999 >     * A {@code SynchronousQueue} has no internal capacity.
1000       *
1001       * @param c the collection
1002 <     * @return <tt>false</tt>
1002 >     * @return {@code false}
1003       */
1004      public boolean removeAll(Collection<?> c) {
1005          return false;
1006      }
1007  
1008      /**
1009 <     * Always returns <tt>false</tt>.
1010 <     * A <tt>SynchronousQueue</tt> has no internal capacity.
1009 >     * Always returns {@code false}.
1010 >     * A {@code SynchronousQueue} has no internal capacity.
1011       *
1012       * @param c the collection
1013 <     * @return <tt>false</tt>
1013 >     * @return {@code false}
1014       */
1015      public boolean retainAll(Collection<?> c) {
1016          return false;
1017      }
1018  
1019      /**
1020 <     * Always returns <tt>null</tt>.
1021 <     * A <tt>SynchronousQueue</tt> does not return elements
1020 >     * Always returns {@code null}.
1021 >     * A {@code SynchronousQueue} does not return elements
1022       * unless actively waited on.
1023       *
1024 <     * @return <tt>null</tt>
1024 >     * @return {@code null}
1025       */
1026      public E peek() {
1027          return null;
1028      }
1029  
1030      /**
1031 <     * Returns an empty iterator in which <tt>hasNext</tt> always returns
1032 <     * <tt>false</tt>.
1031 >     * Returns an empty iterator in which {@code hasNext} always returns
1032 >     * {@code false}.
1033       *
1034       * @return an empty iterator
1035       */
# Line 1057 | Line 1057 | public class SynchronousQueue<E> extends
1057      }
1058  
1059      /**
1060 <     * Sets the zeroeth element of the specified array to <tt>null</tt>
1060 >     * Sets the zeroeth element of the specified array to {@code null}
1061       * (if the array has non-zero length) and returns it.
1062       *
1063       * @param a the array

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines