39 |
|
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> |
40 |
|
* Java Collections Framework</a>. |
41 |
|
* |
42 |
< |
* @since 1.5 |
42 |
> |
* @since 1.7 |
43 |
|
* @author Doug Lea |
44 |
|
* @param <E> the type of elements held in this collection |
45 |
|
* |
49 |
|
private static final long serialVersionUID = -3223113410248163686L; |
50 |
|
|
51 |
|
/* |
52 |
< |
* This is still a work in prgress... |
52 |
> |
* This is still a work in progress... |
53 |
|
* |
54 |
|
* This class extends the approach used in FIFO-mode |
55 |
|
* SynchronousQueues. See the internal documentation, as well as |
160 |
|
/** |
161 |
|
* Puts or takes an item. Used for most queue operations (except |
162 |
|
* poll() and tryTransfer()) |
163 |
< |
* @param e the item or if null, signfies that this is a take |
163 |
> |
* @param e the item or if null, signifies that this is a take |
164 |
|
* @param mode the wait mode: NOWAIT, TIMEOUT, WAIT |
165 |
|
* @param nanos timeout in nanosecs, used only if mode is TIMEOUT |
166 |
|
* @return an item, or null on failure |
206 |
|
|
207 |
|
/** |
208 |
|
* Version of xfer for poll() and tryTransfer, which |
209 |
< |
* simpifies control paths both here and in xfer |
209 |
> |
* simplifies control paths both here and in xfer |
210 |
|
*/ |
211 |
|
private Object fulfill(Object e) { |
212 |
|
boolean isData = (e != null); |
509 |
|
} |
510 |
|
|
511 |
|
/** |
512 |
< |
* Iterators. Basic strategy os to travers list, treating |
512 |
> |
* Iterators. Basic strategy is to traverse list, treating |
513 |
|
* non-data (i.e., request) nodes as terminating list. |
514 |
|
* Once a valid data node is found, the item is cached |
515 |
|
* so that the next call to next() will return it even |
584 |
|
} |
585 |
|
} |
586 |
|
} |
587 |
+ |
|
588 |
+ |
public boolean isEmpty() { |
589 |
+ |
for (;;) { |
590 |
+ |
QNode h = traversalHead(); |
591 |
+ |
QNode p = h.next; |
592 |
+ |
if (p == null) |
593 |
+ |
return true; |
594 |
+ |
Object x = p.get(); |
595 |
+ |
if (p != x) { |
596 |
+ |
if (!p.isData) |
597 |
+ |
return true; |
598 |
+ |
if (x != null) |
599 |
+ |
return false; |
600 |
+ |
} |
601 |
+ |
} |
602 |
+ |
} |
603 |
|
|
604 |
|
public boolean hasWaitingConsumer() { |
605 |
|
for (;;) { |