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 |
682 |
< |
if (p == null) |
683 |
< |
p = head; |
684 |
< |
else if (p.cannotPrecede(haveData)) |
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 |
686 |
< |
(p != n) ? n : null; // restart if off list |
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 |
689 |
|
else { |