39 |
|
*/ |
40 |
|
public interface TransferQueue<E> extends BlockingQueue<E> { |
41 |
|
/** |
42 |
< |
* Transfers the specified element if there exists a consumer |
43 |
< |
* already waiting to receive it, otherwise returning {@code false} |
44 |
< |
* without enqueuing the element. |
42 |
> |
* Transfers the specified element immediately if there exists a |
43 |
> |
* consumer already waiting to receive it (in {@link #take} or |
44 |
> |
* timed {@link #poll(Object,long,TimeUnit) poll}), otherwise |
45 |
> |
* returning {@code false} without enqueuing the element. |
46 |
|
* |
47 |
|
* @param e the element to transfer |
48 |
|
* @return {@code true} if the element was transferred, else |
58 |
|
/** |
59 |
|
* Inserts the specified element into this queue, waiting if |
60 |
|
* necessary for space to become available and the element to be |
61 |
< |
* dequeued by a consumer invoking {@code take} or {@code poll}. |
61 |
> |
* received by a consumer invoking {@code take} or {@code poll}. |
62 |
|
* |
63 |
|
* @param e the element to transfer |
64 |
|
* @throws InterruptedException if interrupted while waiting, |
74 |
|
/** |
75 |
|
* Inserts the specified element into this queue, waiting up to |
76 |
|
* the specified wait time if necessary for space to become |
77 |
< |
* available and the element to be dequeued by a consumer invoking |
77 |
> |
* available and the element to be received by a consumer invoking |
78 |
|
* {@code take} or {@code poll}. |
79 |
|
* |
80 |
|
* @param e the element to transfer |
98 |
|
|
99 |
|
/** |
100 |
|
* Returns {@code true} if there is at least one consumer waiting |
101 |
< |
* to dequeue an element via {@code take} or {@code poll}. |
101 |
> |
* to receive an element via {@link #take} or |
102 |
> |
* timed {@link #poll(Object,long,TimeUnit) poll}. |
103 |
|
* The return value represents a momentary state of affairs. |
104 |
|
* |
105 |
|
* @return {@code true} if there is at least one waiting consumer |
108 |
|
|
109 |
|
/** |
110 |
|
* Returns an estimate of the number of consumers waiting to |
111 |
< |
* dequeue elements via {@code take} or {@code poll}. The return |
111 |
> |
* receive elements via {@link #take} or |
112 |
> |
* timed {@link #poll(Object,long,TimeUnit) poll}. The return |
113 |
|
* value is an approximation of a momentary state of affairs, that |
114 |
|
* may be inaccurate if consumers have completed or given up |
115 |
|
* waiting. The value may be useful for monitoring and heuristics, |
117 |
|
* method are likely to be noticeably slower than those for |
118 |
|
* {@link #hasWaitingConsumer}. |
119 |
|
* |
120 |
< |
* @return the number of consumers waiting to dequeue elements |
120 |
> |
* @return the number of consumers waiting to receive elements |
121 |
|
*/ |
122 |
|
int getWaitingConsumerCount(); |
123 |
|
} |