640 |
|
* if terminated or argument is negative |
641 |
|
*/ |
642 |
|
public int awaitAdvance(int phase) { |
643 |
– |
Phaser rt; |
644 |
– |
int p = (int)(state >>> PHASE_SHIFT); |
643 |
|
if (phase < 0) |
644 |
|
return phase; |
645 |
+ |
int p = (int)(state >>> PHASE_SHIFT); |
646 |
|
if (p == phase) { |
647 |
< |
if ((p = (int)((rt = root).state >>> PHASE_SHIFT)) == phase) |
648 |
< |
return rt.internalAwaitAdvance(phase, null); |
647 |
> |
final Phaser root = this.root; |
648 |
> |
p = (int)(root.state >>> PHASE_SHIFT); |
649 |
> |
if (p == phase) |
650 |
> |
return root.internalAwaitAdvance(phase, null); |
651 |
|
reconcileState(); |
652 |
|
} |
653 |
|
return p; |
669 |
|
*/ |
670 |
|
public int awaitAdvanceInterruptibly(int phase) |
671 |
|
throws InterruptedException { |
671 |
– |
Phaser rt; |
672 |
– |
int p = (int)(state >>> PHASE_SHIFT); |
672 |
|
if (phase < 0) |
673 |
|
return phase; |
674 |
+ |
int p = (int)(state >>> PHASE_SHIFT); |
675 |
|
if (p == phase) { |
676 |
< |
if ((p = (int)((rt = root).state >>> PHASE_SHIFT)) == phase) { |
676 |
> |
final Phaser root = this.root; |
677 |
> |
p = (int)(root.state >>> PHASE_SHIFT); |
678 |
> |
if (p == phase) { |
679 |
|
QNode node = new QNode(this, phase, true, false, 0L); |
680 |
< |
p = rt.internalAwaitAdvance(phase, node); |
680 |
> |
p = root.internalAwaitAdvance(phase, node); |
681 |
|
if (node.wasInterrupted) |
682 |
|
throw new InterruptedException(); |
683 |
|
} |
709 |
|
public int awaitAdvanceInterruptibly(int phase, |
710 |
|
long timeout, TimeUnit unit) |
711 |
|
throws InterruptedException, TimeoutException { |
710 |
– |
long nanos = unit.toNanos(timeout); |
711 |
– |
Phaser rt; |
712 |
– |
int p = (int)(state >>> PHASE_SHIFT); |
712 |
|
if (phase < 0) |
713 |
|
return phase; |
714 |
+ |
long nanos = unit.toNanos(timeout); |
715 |
+ |
int p = (int)(state >>> PHASE_SHIFT); |
716 |
|
if (p == phase) { |
717 |
< |
if ((p = (int)((rt = root).state >>> PHASE_SHIFT)) == phase) { |
717 |
> |
final Phaser root = this.root; |
718 |
> |
p = (int)(root.state >>> PHASE_SHIFT); |
719 |
> |
if (p == phase) { |
720 |
|
QNode node = new QNode(this, phase, true, true, nanos); |
721 |
< |
p = rt.internalAwaitAdvance(phase, node); |
721 |
> |
p = root.internalAwaitAdvance(phase, node); |
722 |
|
if (node.wasInterrupted) |
723 |
|
throw new InterruptedException(); |
724 |
|
else if (p == phase) |