208 |
|
// this doc comment is a modified copy of the inherited doc comment, |
209 |
|
// without the reference to unlimited queues. |
210 |
|
/** |
211 |
< |
* Returns the number of elements that this queue can ideally (in |
212 |
< |
* the absence of memory or resource constraints) accept without |
211 |
> |
* Returns the number of additional elements that this queue can ideally |
212 |
> |
* (in the absence of memory or resource constraints) accept without |
213 |
|
* blocking. This is always equal to the initial capacity of this queue |
214 |
|
* less the current <tt>size</tt> of this queue. |
215 |
< |
* <p>Note that you <em>cannot</em> always tell if |
216 |
< |
* an attempt to <tt>add</tt> an element will succeed by |
217 |
< |
* inspecting <tt>remainingCapacity</tt> because it may be the |
218 |
< |
* case that a waiting consumer is ready to <tt>take</tt> an |
219 |
< |
* element out of an otherwise full queue. |
215 |
> |
* |
216 |
> |
* <p>Note that you <em>cannot</em> always tell if an attempt to insert |
217 |
> |
* an element will succeed by inspecting <tt>remainingCapacity</tt> |
218 |
> |
* because it may be the case that another thread is about to |
219 |
> |
* <tt>put</tt> or <tt>take</tt> an element. |
220 |
|
*/ |
221 |
|
public int remainingCapacity() { |
222 |
|
return capacity - count.get(); |