313 |
|
checkNotNull(e); |
314 |
|
final Node<E> newNode = new Node<E>(e); |
315 |
|
|
316 |
< |
retry: |
316 |
> |
restartFromHead: |
317 |
|
for (;;) { |
318 |
|
for (Node<E> h = head, p = h;;) { |
319 |
|
Node<E> q = p.prev; |
320 |
|
if (q == null) { |
321 |
|
if (p.next == p) // PREV_TERMINATOR |
322 |
< |
continue retry; |
322 |
> |
continue restartFromHead; |
323 |
|
// p is first node |
324 |
|
newNode.lazySetNext(p); // CAS piggyback |
325 |
|
if (p.casPrev(null, newNode)) { |
334 |
|
} |
335 |
|
} |
336 |
|
else if (p == q) |
337 |
< |
continue retry; |
337 |
> |
continue restartFromHead; |
338 |
|
else |
339 |
|
p = q; |
340 |
|
} |
348 |
|
checkNotNull(e); |
349 |
|
final Node<E> newNode = new Node<E>(e); |
350 |
|
|
351 |
< |
retry: |
351 |
> |
restartFromTail: |
352 |
|
for (;;) { |
353 |
|
for (Node<E> t = tail, p = t;;) { |
354 |
|
Node<E> q = p.next; |
355 |
|
if (q == null) { |
356 |
|
if (p.prev == p) // NEXT_TERMINATOR |
357 |
< |
continue retry; |
357 |
> |
continue restartFromTail; |
358 |
|
// p is last node |
359 |
|
newNode.lazySetPrev(p); // CAS piggyback |
360 |
|
if (p.casNext(null, newNode)) { |
369 |
|
} |
370 |
|
} |
371 |
|
else if (p == q) |
372 |
< |
continue retry; |
372 |
> |
continue restartFromTail; |
373 |
|
else |
374 |
|
p = q; |
375 |
|
} |
665 |
|
* Guarantees that head is set to the returned node. |
666 |
|
*/ |
667 |
|
Node<E> first() { |
668 |
< |
retry: |
668 |
> |
restartFromHead: |
669 |
|
for (;;) { |
670 |
|
for (Node<E> h = head, p = h;;) { |
671 |
|
Node<E> q = p.prev; |
676 |
|
|| casHead(h, p)) |
677 |
|
return p; |
678 |
|
else |
679 |
< |
continue retry; |
679 |
> |
continue restartFromHead; |
680 |
|
} else if (p == q) { |
681 |
< |
continue retry; |
681 |
> |
continue restartFromHead; |
682 |
|
} else { |
683 |
|
p = q; |
684 |
|
} |
693 |
|
* Guarantees that tail is set to the returned node. |
694 |
|
*/ |
695 |
|
Node<E> last() { |
696 |
< |
retry: |
696 |
> |
restartFromTail: |
697 |
|
for (;;) { |
698 |
|
for (Node<E> t = tail, p = t;;) { |
699 |
|
Node<E> q = p.next; |
704 |
|
|| casTail(t, p)) |
705 |
|
return p; |
706 |
|
else |
707 |
< |
continue retry; |
707 |
> |
continue restartFromTail; |
708 |
|
} else if (p == q) { |
709 |
< |
continue retry; |
709 |
> |
continue restartFromTail; |
710 |
|
} else { |
711 |
|
p = q; |
712 |
|
} |
1071 |
|
return false; |
1072 |
|
|
1073 |
|
// Atomically splice the chain as the tail of this collection |
1074 |
< |
retry: |
1074 |
> |
restartFromTail: |
1075 |
|
for (;;) { |
1076 |
|
for (Node<E> t = tail, p = t;;) { |
1077 |
|
Node<E> q = p.next; |
1078 |
|
if (q == null) { |
1079 |
|
if (p.prev == p) // NEXT_TERMINATOR |
1080 |
< |
continue retry; |
1080 |
> |
continue restartFromTail; |
1081 |
|
// p is last node |
1082 |
|
splice.lazySetPrev(p); // CAS piggyback |
1083 |
|
if (p.casNext(null, splice)) { |
1094 |
|
} |
1095 |
|
} |
1096 |
|
else if (p == q) |
1097 |
< |
continue retry; |
1097 |
> |
continue restartFromTail; |
1098 |
|
else |
1099 |
|
p = q; |
1100 |
|
} |