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.35 by dl, Sun Aug 23 13:37:08 2009 UTC vs.
Revision 1.37 by jsr166, Mon Aug 24 00:48:52 2009 UTC

# Line 12 | Line 12 | import java.util.concurrent.atomic.Atomi
12   import java.util.concurrent.locks.LockSupport;
13  
14   /**
15 < * A reusable synchronization barrier, similar in functionality to a
15 > * A reusable synchronization barrier, similar in functionality to
16   * {@link java.util.concurrent.CyclicBarrier CyclicBarrier} and
17   * {@link java.util.concurrent.CountDownLatch CountDownLatch}
18   * but supporting more flexible usage.
# Line 27 | Line 27 | import java.util.concurrent.locks.LockSu
27   * #arriveAndDeregister}).  As is the case with most basic
28   * synchronization constructs, registration and deregistration affect
29   * only internal counts; they do not establish any further internal
30 < * bookkeeping, so tasks cannot query whether they are
31 < * registered. (However, you can introduce such bookkeeping by
32 < * subclassing this class.)
33 < *
34 < * <li> Each generation has an associated phase value, starting at
35 < * zero, and advancing when all parties arrive at the barrier
36 < * (wrapping around to zero after reaching {@code Integer.MAX_VALUE}).
30 > * bookkeeping, so tasks cannot query whether they are registered.
31 > * (However, you can introduce such bookkeeping by subclassing this
32 > * class.)
33 > *
34 > * <li> Each generation has an associated phase number. The phase
35 > * number starts at zero, amd advances when all parties arrive at the
36 > * barrier, wrapping around to zero after reaching {@code
37 > * Integer.MAX_VALUE}.
38   *
39   * <li> Like a {@code CyclicBarrier}, a phaser may be repeatedly
40   * awaited.  Method {@link #arriveAndAwaitAdvance} has effect
# Line 54 | Line 55 | import java.util.concurrent.locks.LockSu
55   *       when the barrier advances to a new phase.
56   * </ul>
57   *
57 *
58   * <li> Barrier actions, performed by the task triggering a phase
59   * advance, are arranged by overriding method {@link #onAdvance(int,
60   * int)}, which also controls termination. Overriding this method is
# Line 90 | Line 90 | import java.util.concurrent.locks.LockSu
90   * ForkJoinPool}, which will ensure sufficient parallelism to execute
91   * tasks when others are blocked waiting for a phase to advance.
92   *
93 + * <li>The current state of a phaser may be monitored.  At any given
94 + * moment there are {@link #getRegisteredParties}, where {@link
95 + * #getArrivedParties} have arrived at the current phase ({@link
96 + * #getPhase}). When the remaining {@link #getUnarrivedParties})
97 + * arrive, the phase advances. Method {@link #toString} returns
98 + * snapshots of these state queries in a form convenient for
99 + * informal monitoring.
100 + *
101   * </ul>
102   *
103   * <p><b>Sample usages:</b>
# Line 666 | Line 674 | public class Phaser {
674      }
675  
676      /**
677 <     * Returns the number of parties that have arrived at the current
678 <     * phase of this barrier.
677 >     * Returns the number of registered parties that have arrived at
678 >     * the current phase of this barrier.
679       *
680       * @return the number of arrived parties
681       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines