219 |
|
Node<E> t = tail.get(); |
220 |
|
Node<E> h = head.get(); |
221 |
|
|
222 |
< |
if (t != null && (t == h || t.isData == isData)) { |
222 |
> |
if (t == h || t.isData == isData) { |
223 |
|
if (s == null) |
224 |
|
s = new Node<E>(e, isData); |
225 |
|
Node<E> last = t.next; |
231 |
|
tail.compareAndSet(t, s); |
232 |
|
return awaitFulfill(t, s, e, mode, nanos); |
233 |
|
} |
234 |
< |
} |
235 |
< |
|
236 |
< |
else if (h != null) { |
234 |
> |
} else { |
235 |
|
Node<E> first = h.next; |
236 |
|
if (t == tail.get() && first != null && |
237 |
|
advanceHead(h, first)) { |
259 |
|
Node<E> t = tail.get(); |
260 |
|
Node<E> h = head.get(); |
261 |
|
|
262 |
< |
if (t != null && (t == h || t.isData == isData)) { |
262 |
> |
if (t == h || t.isData == isData) { |
263 |
|
Node<E> last = t.next; |
264 |
|
if (t == tail.get()) { |
265 |
|
if (last != null) |
267 |
|
else |
268 |
|
return null; |
269 |
|
} |
270 |
< |
} |
273 |
< |
else if (h != null) { |
270 |
> |
} else { |
271 |
|
Node<E> first = h.next; |
272 |
|
if (t == tail.get() && |
273 |
|
first != null && |
329 |
|
} |
330 |
|
if (spins < 0) { |
331 |
|
Node<E> h = head.get(); // only spin if at head |
332 |
< |
spins = ((h != null && h.next == s) ? |
333 |
< |
((mode == TIMEOUT) ? |
334 |
< |
maxTimedSpins : maxUntimedSpins) : 0); |
332 |
> |
spins = ((h.next != s) ? 0 : |
333 |
> |
(mode == TIMEOUT) ? maxTimedSpins : |
334 |
> |
maxUntimedSpins); |
335 |
|
} |
336 |
|
if (spins > 0) |
337 |
|
--spins; |
640 |
|
for (;;) { |
641 |
|
Node<E> t = tail.get(); |
642 |
|
Node<E> h = head.get(); |
643 |
< |
if (h != null && t != null) { |
644 |
< |
Node<E> last = t.next; |
645 |
< |
Node<E> first = h.next; |
646 |
< |
if (t == tail.get()) { |
647 |
< |
if (last != null) |
648 |
< |
tail.compareAndSet(t, last); |
649 |
< |
else if (first != null) { |
650 |
< |
Object x = first.get(); |
651 |
< |
if (x == first) |
655 |
< |
advanceHead(h, first); |
656 |
< |
else |
657 |
< |
return h; |
658 |
< |
} |
643 |
> |
Node<E> last = t.next; |
644 |
> |
Node<E> first = h.next; |
645 |
> |
if (t == tail.get()) { |
646 |
> |
if (last != null) |
647 |
> |
tail.compareAndSet(t, last); |
648 |
> |
else if (first != null) { |
649 |
> |
Object x = first.get(); |
650 |
> |
if (x == first) |
651 |
> |
advanceHead(h, first); |
652 |
|
else |
653 |
|
return h; |
654 |
|
} |
655 |
+ |
else |
656 |
+ |
return h; |
657 |
|
} |
658 |
|
reclean(); |
659 |
|
} |