ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Phaser.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/Phaser.java (file contents):
Revision 1.46 by jsr166, Fri Dec 3 22:07:08 2010 UTC vs.
Revision 1.47 by jsr166, Fri Dec 3 23:00:29 2010 UTC

# Line 640 | Line 640 | public class Phaser {
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;
# Line 668 | Line 669 | public class Phaser {
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              }
# Line 707 | Line 709 | public class Phaser {
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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines