12 |
|
* to receive elements. A <tt>TransferQueue</tt> may be useful for |
13 |
|
* example in message passing applications in which producers |
14 |
|
* sometimes (using method <tt>transfer</tt>) await receipt of |
15 |
< |
* elements by consumers invoking <tt>take</tt> or <tt>poll</tt>, while |
16 |
< |
* at other times enqueue elements (via method <tt>put</tt>) without |
17 |
< |
* waiting for receipt. Non-blocking and time-out versions of |
18 |
< |
* <tt>tryTransfer</tt> are also available. |
15 |
> |
* elements by consumers invoking <tt>take</tt> or <tt>poll</tt>, |
16 |
> |
* while at other times enqueue elements (via method <tt>put</tt>) |
17 |
> |
* without waiting for receipt. Non-blocking and time-out versions of |
18 |
> |
* <tt>tryTransfer</tt> are also available. A TransferQueue may also |
19 |
> |
* be queried via <tt>hasWaitingConsumer</tt> whether there are any |
20 |
> |
* threads waiting for items, which is a converse analogy to a |
21 |
> |
* <tt>peek</tt> operation |
22 |
|
* |
23 |
|
* <p>Like any <tt>BlockingQueue</tt>, a <tt>TransferQueue</tt> may be |
24 |
|
* capacity bounded. If so, an attempted <tt>transfer</tt> operation |
96 |
|
/** |
97 |
|
* Returns true if there is at least one consumer waiting to |
98 |
|
* dequeue an element via <tt>take</tt> or <tt>poll</tt>. The |
99 |
< |
* return value represents a momentary state of affairs, that |
97 |
< |
* may be useful for monitoring and heuristics, but not |
98 |
< |
* for synchronization control. |
99 |
> |
* return value represents a momentary state of affairs. |
100 |
|
* @return true if there is at least one waiting consumer. |
101 |
|
*/ |
102 |
|
boolean hasWaitingConsumer(); |
105 |
|
/** |
106 |
|
* Returns an estimate of the number of consumers waiting to |
107 |
|
* dequeue elements via <tt>take</tt> or <tt>poll</tt>. The return |
108 |
< |
* value represents a momentary state of affairs, that may be |
109 |
< |
* useful for monitoring and heuristics, but not for |
110 |
< |
* synchronization control. Implementations of this method are |
111 |
< |
* likely to be noticeably slower than those for |
108 |
> |
* value is an approximation of a momentary state of affairs, that |
109 |
> |
* may be inaccurate if consumers have completed or given up |
110 |
> |
* waiting. The value may be useful for monitoring and heuristics, |
111 |
> |
* but not for synchronization control. Implementations of this |
112 |
> |
* method are likely to be noticeably slower than those for |
113 |
|
* <tt>hasWaitingConsumer</tt>. |
114 |
|
* @return the number of consumers waiting to dequeue elements |
115 |
|
*/ |