680 |
|
@SuppressWarnings("unchecked") E itemE = (E) item; |
681 |
|
return itemE; |
682 |
|
} |
683 |
< |
if ((w.isInterrupted() || (timed && nanos <= 0)) && |
684 |
< |
s.casItem(e, s)) { // cancel |
685 |
< |
unsplice(pred, s); |
686 |
< |
return e; |
683 |
> |
else if (w.isInterrupted() || (timed && nanos <= 0)) { |
684 |
> |
unsplice(pred, s); // try to unlink and cancel |
685 |
> |
if (s.casItem(e, s)) // return normally if lost CAS |
686 |
> |
return e; |
687 |
|
} |
688 |
< |
|
689 |
< |
if (spins < 0) { // establish spins at/near front |
688 |
> |
else if (spins < 0) { // establish spins at/near front |
689 |
|
if ((spins = spinsFor(pred, s.isData)) > 0) |
690 |
|
randomYields = ThreadLocalRandom.current(); |
691 |
|
} |
1022 |
|
* @param s the node to be unspliced |
1023 |
|
*/ |
1024 |
|
final void unsplice(Node pred, Node s) { |
1025 |
< |
s.forgetContents(); // forget unneeded fields |
1025 |
> |
s.waiter = null; // disable signals |
1026 |
|
/* |
1027 |
|
* See above for rationale. Briefly: if pred still points to |
1028 |
|
* s, try to unlink s. If s cannot be unlinked, because it is |