94 |
|
* |
95 |
|
* A new element is added atomically by CASing the null prev or |
96 |
|
* next reference in the first or last node to a fresh node |
97 |
< |
* containing the element. |
97 |
> |
* containing the element. The element's node atomically becomes |
98 |
> |
* "live" at that point. |
99 |
|
* |
100 |
|
* A node is considered "active" if it is a live node, or the |
101 |
|
* first or last node. Active nodes cannot be unlinked. |
323 |
|
// p is first node |
324 |
|
newNode.lazySetNext(p); // CAS piggyback |
325 |
|
if (p.casPrev(null, newNode)) { |
326 |
+ |
// Successful CAS is the linearization point |
327 |
+ |
// for e to become an element of this deque, |
328 |
+ |
// and for newNode to become "live". |
329 |
|
if (p != h) // hop two nodes at a time |
330 |
|
casHead(h, newNode); |
331 |
|
return; |
358 |
|
// p is last node |
359 |
|
newNode.lazySetPrev(p); // CAS piggyback |
360 |
|
if (p.casNext(null, newNode)) { |
361 |
+ |
// Successful CAS is the linearization point |
362 |
+ |
// for e to become an element of this deque, |
363 |
+ |
// and for newNode to become "live". |
364 |
|
if (p != t) // hop two nodes at a time |
365 |
|
casTail(t, newNode); |
366 |
|
return; |