678 |
|
// assert tail != null; |
679 |
|
// assert s.isData == haveData; |
680 |
|
for (Node t = tail, p = t;;) { // move p to last node and append |
681 |
< |
Node n, u; // temps for reads of next & tail |
681 |
> |
Node n; |
682 |
|
if (p.cannotPrecede(haveData)) |
683 |
|
return null; // lost race vs opposite mode |
684 |
|
else if ((n = p.next) != null) // not last; keep traversing |
685 |
< |
p = p != t && t != (u = tail) ? (t = u) : // stale tail |
685 |
> |
p = (p != t && t != (t = tail)) ? t : // stale tail |
686 |
|
(p != n) ? n : head; // restart if off list |
687 |
|
else if (!p.casNext(null, s)) |
688 |
|
p = p.next; // re-read on CAS failure |