326 |
|
else if (y == null && // Try to occupy |
327 |
|
slot.compareAndSet(null, me)) { |
328 |
|
if (index == 0) // Blocking wait for slot 0 |
329 |
< |
return timed? awaitNanos(me, slot, nanos): await(me, slot); |
329 |
> |
return timed ? |
330 |
> |
awaitNanos(me, slot, nanos) : |
331 |
> |
await(me, slot); |
332 |
|
Object v = spinWait(me, slot); // Spin wait for non-0 |
333 |
|
if (v != CANCEL) |
334 |
|
return v; |
589 |
|
*/ |
590 |
|
public V exchange(V x) throws InterruptedException { |
591 |
|
if (!Thread.interrupted()) { |
592 |
< |
Object v = doExchange(x == null? NULL_ITEM : x, false, 0); |
592 |
> |
Object v = doExchange((x == null) ? NULL_ITEM : x, false, 0); |
593 |
|
if (v == NULL_ITEM) |
594 |
|
return null; |
595 |
|
if (v != CANCEL) |
644 |
|
public V exchange(V x, long timeout, TimeUnit unit) |
645 |
|
throws InterruptedException, TimeoutException { |
646 |
|
if (!Thread.interrupted()) { |
647 |
< |
Object v = doExchange(x == null? NULL_ITEM : x, |
647 |
> |
Object v = doExchange((x == null) ? NULL_ITEM : x, |
648 |
|
true, unit.toNanos(timeout)); |
649 |
|
if (v == NULL_ITEM) |
650 |
|
return null; |