16 |
|
import java.util.concurrent.atomic.AtomicReference; |
17 |
|
|
18 |
|
/** |
19 |
< |
* An unbounded {@linkplain TransferQueue} based on linked nodes. |
19 |
> |
* An unbounded {@link TransferQueue} based on linked nodes. |
20 |
|
* This queue orders elements FIFO (first-in-first-out) with respect |
21 |
|
* to any given producer. The <em>head</em> of the queue is that |
22 |
|
* element that has been on the queue the longest time for some |
492 |
|
} |
493 |
|
|
494 |
|
/** |
495 |
< |
* Transfers the specified element immediately if there exists a |
496 |
< |
* consumer already waiting to receive it (in {@link #take} or |
497 |
< |
* timed {@link #poll(long,TimeUnit) poll}), otherwise |
498 |
< |
* returning {@code false} without enqueuing the element. |
495 |
> |
* Transfers the element to a waiting consumer immediately, if possible. |
496 |
> |
* |
497 |
> |
* <p>More precisely, transfers the specified element immediately |
498 |
> |
* if there exists a consumer already waiting to receive it (in |
499 |
> |
* {@link #take} or timed {@link #poll(long,TimeUnit) poll}), |
500 |
> |
* otherwise returning {@code false} without enqueuing the element. |
501 |
|
* |
502 |
|
* @throws NullPointerException if the specified element is null |
503 |
|
*/ |
507 |
|
} |
508 |
|
|
509 |
|
/** |
510 |
< |
* Inserts the specified element at the tail of this queue, |
511 |
< |
* waiting if necessary for the element to be received by a |
512 |
< |
* consumer invoking {@code take} or {@code poll}. |
510 |
> |
* Transfers the element to a consumer, waiting if necessary to do so. |
511 |
> |
* |
512 |
> |
* <p>More precisely, transfers the specified element immediately |
513 |
> |
* if there exists a consumer already waiting to receive it (in |
514 |
> |
* {@link #take} or timed {@link #poll(long,TimeUnit) poll}), |
515 |
> |
* else inserts the specified element at the tail of this queue |
516 |
> |
* and waits until the element is received by a consumer. |
517 |
|
* |
518 |
|
* @throws NullPointerException if the specified element is null |
519 |
|
*/ |
526 |
|
} |
527 |
|
|
528 |
|
/** |
529 |
< |
* Inserts the specified element at the tail of this queue, |
530 |
< |
* waiting up to the specified wait time if necessary for the |
531 |
< |
* element to be received by a consumer invoking {@code take} or |
532 |
< |
* {@code poll}. |
529 |
> |
* Transfers the element to a consumer if it is possible to do so |
530 |
> |
* before the timeout elapses. |
531 |
> |
* |
532 |
> |
* <p>More precisely, transfers the specified element immediately |
533 |
> |
* if there exists a consumer already waiting to receive it (in |
534 |
> |
* {@link #take} or timed {@link #poll(long,TimeUnit) poll}), |
535 |
> |
* else inserts the specified element at the tail of this queue |
536 |
> |
* and waits until the element is received by a consumer, |
537 |
> |
* returning {@code false} if the specified wait time elapses |
538 |
> |
* before the element can be transferred. |
539 |
|
* |
540 |
|
* @throws NullPointerException if the specified element is null |
541 |
|
*/ |
732 |
|
} |
733 |
|
} |
734 |
|
|
735 |
+ |
/** |
736 |
+ |
* Returns {@code true} if this queue contains no elements. |
737 |
+ |
* |
738 |
+ |
* @return {@code true} if this queue contains no elements |
739 |
+ |
*/ |
740 |
|
public boolean isEmpty() { |
741 |
|
for (;;) { |
742 |
|
Node<E> h = traversalHead(); |
818 |
|
} |
819 |
|
} |
820 |
|
|
821 |
+ |
/** |
822 |
+ |
* Removes a single instance of the specified element from this queue, |
823 |
+ |
* if it is present. More formally, removes an element {@code e} such |
824 |
+ |
* that {@code o.equals(e)}, if this queue contains one or more such |
825 |
+ |
* elements. |
826 |
+ |
* Returns {@code true} if this queue contained the specified element |
827 |
+ |
* (or equivalently, if this queue changed as a result of the call). |
828 |
+ |
* |
829 |
+ |
* @param o element to be removed from this queue, if present |
830 |
+ |
* @return {@code true} if this queue changed as a result of the call |
831 |
+ |
*/ |
832 |
|
public boolean remove(Object o) { |
833 |
|
if (o == null) |
834 |
|
return false; |