40 |
|
* @author Doug Lea |
41 |
|
* @param <E> the type of elements held in this collection |
42 |
|
* |
43 |
< |
**/ |
43 |
> |
*/ |
44 |
|
public class LinkedBlockingQueue<E> extends AbstractQueue<E> |
45 |
|
implements BlockingQueue<E>, java.io.Serializable { |
46 |
|
private static final long serialVersionUID = -6903933977591709194L; |
94 |
|
private final Condition notFull = putLock.newCondition(); |
95 |
|
|
96 |
|
/** |
97 |
< |
* Signal a waiting take. Called only from put/offer (which do not |
97 |
> |
* Signals a waiting take. Called only from put/offer (which do not |
98 |
|
* otherwise ordinarily lock takeLock.) |
99 |
|
*/ |
100 |
|
private void signalNotEmpty() { |
108 |
|
} |
109 |
|
|
110 |
|
/** |
111 |
< |
* Signal a waiting put. Called only from take/poll. |
111 |
> |
* Signals a waiting put. Called only from take/poll. |
112 |
|
*/ |
113 |
|
private void signalNotFull() { |
114 |
|
final ReentrantLock putLock = this.putLock; |
121 |
|
} |
122 |
|
|
123 |
|
/** |
124 |
< |
* Create a node and link it at end of queue |
124 |
> |
* Creates a node and links it at end of queue. |
125 |
|
* @param x the item |
126 |
|
*/ |
127 |
|
private void insert(E x) { |
129 |
|
} |
130 |
|
|
131 |
|
/** |
132 |
< |
* Remove a node from head of queue, |
132 |
> |
* Removes a node from head of queue, |
133 |
|
* @return the node |
134 |
|
*/ |
135 |
|
private E extract() { |
185 |
|
* added in traversal order of the collection's iterator. |
186 |
|
* @param c the collection of elements to initially contain |
187 |
|
* @throws NullPointerException if <tt>c</tt> or any element within it |
188 |
< |
* is <tt>null</tt> |
188 |
> |
* is <tt>null</tt>. |
189 |
|
*/ |
190 |
|
public LinkedBlockingQueue(Collection<? extends E> c) { |
191 |
|
this(Integer.MAX_VALUE); |
320 |
|
* @param o the element to add. |
321 |
|
* @return <tt>true</tt> if it was possible to add the element to |
322 |
|
* this queue, else <tt>false</tt> |
323 |
< |
* @throws NullPointerException if the specified element is <tt>null</tt> |
323 |
> |
* @throws NullPointerException if the specified element is <tt>null</tt>. |
324 |
|
*/ |
325 |
|
public boolean offer(E o) { |
326 |
|
if (o == null) throw new NullPointerException(); |
562 |
|
} |
563 |
|
return n; |
564 |
|
} |
565 |
< |
|
565 |
> |
|
566 |
|
public int drainTo(Collection<? super E> c, int maxElements) { |
567 |
|
if (c == null) |
568 |
|
throw new NullPointerException(); |
595 |
|
/** |
596 |
|
* Returns an iterator over the elements in this queue in proper sequence. |
597 |
|
* The returned <tt>Iterator</tt> is a "weakly consistent" iterator that |
598 |
< |
* will never throw {@link java.util.ConcurrentModificationException}, |
598 |
> |
* will never throw {@link ConcurrentModificationException}, |
599 |
|
* and guarantees to traverse elements as they existed upon |
600 |
|
* construction of the iterator, and may (but is not guaranteed to) |
601 |
|
* reflect any modifications subsequent to construction. |