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.8 by jsr166, Mon Jan 5 05:50:47 2009 UTC vs.
Revision 1.9 by jsr166, Mon Jan 5 09:11:26 2009 UTC

# Line 5 | Line 5
5   */
6  
7   package jsr166y;
8 +
9   import java.util.concurrent.*;
10   import java.util.concurrent.atomic.*;
11   import java.util.concurrent.locks.LockSupport;
# Line 13 | Line 14 | import java.lang.reflect.*;
14  
15   /**
16   * A reusable synchronization barrier, similar in functionality to a
17 < * {@link java.util.concurrent.CyclicBarrier} and {@link
18 < * java.util.concurrent.CountDownLatch} but supporting more flexible
19 < * usage.
17 > * {@link java.util.concurrent.CyclicBarrier CyclicBarrier} and
18 > * {@link java.util.concurrent.CountDownLatch CountDownLatch}
19 > * but supporting more flexible usage.
20   *
21   * <ul>
22   *
# Line 25 | Line 26 | import java.lang.reflect.*;
26   * basic synchronization constructs, registration and deregistration
27   * affect only internal counts; they do not establish any further
28   * internal bookkeeping, so tasks cannot query whether they are
29 < * registered. (However, you can introduce such bookkeeping in by
29 > * registered. (However, you can introduce such bookkeeping by
30   * subclassing this class.)
31   *
32   * <li> Each generation has an associated phase value, starting at
# Line 617 | Line 618 | public class Phaser {
618      }
619  
620      /**
621 <     * Returns true if the current phase number equals the given phase.
621 >     * Returns {@code true} if the current phase number equals the given phase.
622       * @param phase the phase
623 <     * @return true if the current phase number equals the given phase.
623 >     * @return {@code true} if the current phase number equals the given phase
624       */
625      public final boolean hasPhase(int phase) {
626          return phaseOf(getReconciledState()) == phase;
# Line 653 | Line 654 | public class Phaser {
654  
655      /**
656       * Returns the parent of this phaser, or null if none.
657 <     * @return the parent of this phaser, or null if none.
657 >     * @return the parent of this phaser, or null if none
658       */
659      public Phaser getParent() {
660          return parent;
# Line 662 | Line 663 | public class Phaser {
663      /**
664       * Returns the root ancestor of this phaser, which is the same as
665       * this phaser if it has no parent.
666 <     * @return the root ancestor of this phaser.
666 >     * @return the root ancestor of this phaser
667       */
668      public Phaser getRoot() {
669          return root;
670      }
671  
672      /**
673 <     * Returns true if this barrier has been terminated.
674 <     * @return true if this barrier has been terminated
673 >     * Returns {@code true} if this barrier has been terminated.
674 >     * @return {@code true} if this barrier has been terminated
675       */
676      public boolean isTerminated() {
677          return getPhase() < 0;
# Line 702 | Line 703 | public class Phaser {
703       * method.
704       *
705       * @param phase the phase number on entering the barrier
706 <     * @param registeredParties the current number of registered
707 <     * parties.
707 <     * @return true if this barrier should terminate
706 >     * @param registeredParties the current number of registered parties
707 >     * @return {@code true} if this barrier should terminate
708       */
709      protected boolean onAdvance(int phase, int registeredParties) {
710          return registeredParties <= 0;
# Line 713 | Line 713 | public class Phaser {
713      /**
714       * Returns a string identifying this phaser, as well as its
715       * state.  The state, in brackets, includes the String {@code
716 <     * "phase ="} followed by the phase number, {@code "parties ="}
716 >     * "phase = "} followed by the phase number, {@code "parties = "}
717       * followed by the number of registered parties, and {@code
718 <     * "arrived ="} followed by the number of arrived parties
718 >     * "arrived = "} followed by the number of arrived parties.
719       *
720       * @return a string identifying this barrier, as well as its state
721       */
722      public String toString() {
723          long s = getReconciledState();
724 <        return super.toString() + "[phase = " + phaseOf(s) + " parties = " + partiesOf(s) + " arrived = " + arrivedOf(s) + "]";
724 >        return super.toString() +
725 >            "[phase = " + phaseOf(s) +
726 >            " parties = " + partiesOf(s) +
727 >            " arrived = " + arrivedOf(s) + "]";
728      }
729  
730      // methods for waiting

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines