732 |
|
} |
733 |
|
|
734 |
|
/** |
735 |
< |
* Returns the first unmatched node of the given mode, or null if |
736 |
< |
* none. Used by hasWaitingConsumer. |
737 |
< |
*/ |
738 |
< |
private Node firstOfMode(boolean isData) { |
739 |
< |
for (Node p = head; p != null; p = succ(p)) { |
740 |
< |
if (!p.isMatched()) |
741 |
< |
return (p.isData == isData) ? p : null; |
742 |
< |
} |
743 |
< |
return null; |
744 |
< |
} |
745 |
< |
|
746 |
< |
/** |
747 |
< |
* Version of firstOfMode used by Spliterator. Callers must |
748 |
< |
* recheck if the returned node's item field is null or |
749 |
< |
* self-linked before using. |
735 |
> |
* Returns the first unmatched data node, or null if none. |
736 |
> |
* Callers must recheck if the returned node's item field is null |
737 |
> |
* or self-linked before using. |
738 |
|
*/ |
739 |
|
final Node firstDataNode() { |
740 |
|
restartFromHead: for (;;) { |
1416 |
|
} |
1417 |
|
|
1418 |
|
public boolean hasWaitingConsumer() { |
1419 |
< |
return firstOfMode(false) != null; |
1419 |
> |
restartFromHead: for (;;) { |
1420 |
> |
for (Node p = head; p != null;) { |
1421 |
> |
Object item = p.item; |
1422 |
> |
if (p.isData) { |
1423 |
> |
if (item != null && item != p) |
1424 |
> |
break; |
1425 |
> |
} |
1426 |
> |
else if (item == null) |
1427 |
> |
return true; |
1428 |
> |
if (p == (p = p.next)) |
1429 |
> |
continue restartFromHead; |
1430 |
> |
} |
1431 |
> |
return false; |
1432 |
> |
} |
1433 |
|
} |
1434 |
|
|
1435 |
|
/** |