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

Comparing jsr166/src/jsr166y/Phaser.java (file contents):
Revision 1.68 by dl, Sat Dec 4 15:25:08 2010 UTC vs.
Revision 1.69 by jsr166, Sat Dec 4 22:00:05 2010 UTC

# Line 77 | Line 77 | import java.util.concurrent.locks.LockSu
77   * <p> <b>Termination.</b> A phaser may enter a <em>termination</em>
78   * state, that may be checked using method {@link #isTerminated}. Upon
79   * termination, all synchronization methods immediately return without
80 < * waiting for advance, as indicated by a negative return
81 < * value. Similarly, attempts to register upon termination have no
82 < * effect.  Termination is triggered when an invocation of {@code
83 < * onAdvance} returns {@code true}. The default implementation returns
84 < * {@code true} if a deregistration has caused the number of
85 < * registered parties to become zero.  As illustrated below, when
86 < * phasers control actions with a fixed number of iterations, it is
87 < * often convenient to override this method to cause termination when
88 < * the current phase number reaches a threshold. Method {@link
89 < * #forceTermination} is also available to abruptly release waiting
90 < * threads and allow them to terminate.
80 > * waiting for advance, as indicated by a negative return value.
81 > * Similarly, attempts to register upon termination have no effect.
82 > * Termination is triggered when an invocation of {@code onAdvance}
83 > * returns {@code true}. The default implementation returns {@code
84 > * true} if a deregistration has caused the number of registered
85 > * parties to become zero.  As illustrated below, when phasers control
86 > * actions with a fixed number of iterations, it is often convenient
87 > * to override this method to cause termination when the current phase
88 > * number reaches a threshold. Method {@link #forceTermination} is
89 > * also available to abruptly release waiting threads and allow them
90 > * to terminate.
91   *
92   * <p> <b>Tiering.</b> Phasers may be <em>tiered</em> (i.e.,
93   * constructed in tree structures) to reduce contention. Phasers with
# Line 541 | Line 541 | public class Phaser {
541       *
542       * @return the arrival phase number to which this registration
543       * applied.  If this value is negative, then this phaser has
544 <     * terminated, in which casem registration has no effect.
544 >     * terminated, in which case registration has no effect.
545       * @throws IllegalStateException if attempting to register more
546       * than the maximum supported number of parties
547       */
# Line 563 | Line 563 | public class Phaser {
563       * advance to the next phase
564       * @return the arrival phase number to which this registration
565       * applied.  If this value is negative, then this phaser has
566 <     * terminated, in which casem registration has no effect.
566 >     * terminated, in which case registration has no effect.
567       * @throws IllegalStateException if attempting to register more
568       * than the maximum supported number of parties
569       * @throws IllegalArgumentException if {@code parties < 0}
# Line 682 | Line 682 | public class Phaser {
682       */
683      public int awaitAdvance(int phase) {
684          final Phaser root = this.root;
685 <        int p = (int)((root == this? state : reconcileState()) >>> PHASE_SHIFT);
685 >        long s = (root == this) ? state : reconcileState();
686 >        int p = (int)(s >>> PHASE_SHIFT);
687          if (phase < 0)
688              return phase;
689          if (p == phase)
# Line 708 | Line 709 | public class Phaser {
709      public int awaitAdvanceInterruptibly(int phase)
710          throws InterruptedException {
711          final Phaser root = this.root;
712 <        int p = (int)((root == this? state : reconcileState()) >>> PHASE_SHIFT);
712 >        long s = (root == this) ? state : reconcileState();
713 >        int p = (int)(s >>> PHASE_SHIFT);
714          if (phase < 0)
715              return phase;
716          if (p == phase) {
# Line 745 | Line 747 | public class Phaser {
747          throws InterruptedException, TimeoutException {
748          long nanos = unit.toNanos(timeout);
749          final Phaser root = this.root;
750 <        int p = (int)((root == this? state : reconcileState()) >>> PHASE_SHIFT);
750 >        long s = (root == this) ? state : reconcileState();
751 >        int p = (int)(s >>> PHASE_SHIFT);
752          if (phase < 0)
753              return phase;
754          if (p == phase) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines