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.34 by dl, Wed Aug 19 23:05:32 2009 UTC vs.
Revision 1.35 by dl, Sun Aug 23 13:37:08 2009 UTC

# Line 19 | Line 19 | import java.util.concurrent.locks.LockSu
19   *
20   * <ul>
21   *
22 < * <li> The number of parties synchronizing on a phaser may vary over
23 < * time.  A task may register to be a party at any time, and may
24 < * deregister upon arriving at the barrier.  As is the case with most
25 < * basic synchronization constructs, registration and deregistration
26 < * affect only internal counts; they do not establish any further
27 < * internal bookkeeping, so tasks cannot query whether they are
22 > * <li> The number of parties <em>registered</em> to synchronize on a
23 > * phaser may vary over time.  Tasks may be registered at any time
24 > * (using methods {@link #register}, {@link #bulkRegister}, or forms
25 > * of constructors establishing initial numbers of parties), and may
26 > * optionally be deregistered upon any arrival (using {@link
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 reach the barrier (wrapping
36 < * around to zero after reaching {@code Integer.MAX_VALUE}).
35 > * zero, and advancing when all parties arrive at the barrier
36 > * (wrapping around to zero after reaching {@code Integer.MAX_VALUE}).
37   *
38   * <li> Like a {@code CyclicBarrier}, a phaser may be repeatedly
39   * awaited.  Method {@link #arriveAndAwaitAdvance} has effect
# Line 42 | Line 45 | import java.util.concurrent.locks.LockSu
45   *
46   *   <li> Arriving at a barrier. Methods {@link #arrive} and
47   *       {@link #arriveAndDeregister} do not block, but return
48 < *       the phase value current upon entry to the method.
48 > *       an associated <em>arrival phase number</em>;
49 > *       that is, the phase number of the barrier to which the
50 > *       arrival applied.
51   *
52   *   <li> Awaiting others. Method {@link #awaitAdvance} requires an
53 < *       argument indicating the entry phase, and returns when the
54 < *       barrier advances to a new phase.
53 > *       argument indicating an arrival phase number, and returns
54 > *       when the barrier advances to a new phase.
55   * </ul>
56   *
57   *
# Line 366 | Line 371 | public class Phaser {
371      /**
372       * Adds a new unarrived party to this phaser.
373       *
374 <     * @return the current barrier phase number upon registration
374 >     * @return the arrival phase number to which this registration applied
375       * @throws IllegalStateException if attempting to register more
376       * than the maximum supported number of parties
377       */
# Line 378 | Line 383 | public class Phaser {
383       * Adds the given number of new unarrived parties to this phaser.
384       *
385       * @param parties the number of parties required to trip barrier
386 <     * @return the current barrier phase number upon registration
386 >     * @return the arrival phase number to which this registration applied
387       * @throws IllegalStateException if attempting to register more
388       * than the maximum supported number of parties
389       */
# Line 415 | Line 420 | public class Phaser {
420       * Arrives at the barrier, but does not wait for others.  (You can
421       * in turn wait for others via {@link #awaitAdvance}).
422       *
423 <     * @return the barrier phase number upon entry to this method, or a
419 <     * negative value if terminated
423 >     * @return the arrival phase number, or a negative value if terminated
424       * @throws IllegalStateException if not terminated and the number
425       * of unarrived parties would become negative
426       */
# Line 468 | Line 472 | public class Phaser {
472       * zero parties, this phaser also arrives at and is deregistered
473       * from its parent.
474       *
475 <     * @return the current barrier phase number upon entry to
472 <     * this method, or a negative value if terminated
475 >     * @return the arrival phase number, or a negative value if terminated
476       * @throws IllegalStateException if not terminated and the number
477       * of registered or unarrived parties would become negative
478       */
# Line 525 | Line 528 | public class Phaser {
528       * method.  If instead you need to deregister upon arrival use
529       * {@code arriveAndDeregister}.
530       *
531 <     * @return the phase on entry to this method
531 >     * @return the arrival phase number, or a negative number if terminated
532       * @throws IllegalStateException if not terminated and the number
533       * of unarrived parties would become negative
534       */
# Line 539 | Line 542 | public class Phaser {
542       * barrier is not equal to the given phase value or this barrier
543       * is terminated.
544       *
545 <     * @param phase the phase on entry to this method
546 <     * @return the current barrier phase number upon exit of
547 <     * this method, or a negative value if terminated or
548 <     * argument is negative
545 >     * @param phase an arrival phase number, or negative value if
546 >     * terminated; this argument is normally the value returned by a
547 >     * previous call to {@code arrive} or its variants
548 >     * @return the next arrival phase number, or a negative value
549 >     * if terminated or argument is negative
550       */
551      public int awaitAdvance(int phase) {
552          if (phase < 0)
# Line 564 | Line 568 | public class Phaser {
568       * barrier is not equal to the given phase value or this barrier
569       * is terminated.
570       *
571 <     * @param phase the phase on entry to this method
572 <     * @return the current barrier phase number upon exit of
573 <     * this method, or a negative value if terminated or
574 <     * argument is negative
571 >     * @param phase an arrival phase number, or negative value if
572 >     * terminated; this argument is normally the value returned by a
573 >     * previous call to {@code arrive} or its variants
574 >     * @return the next arrival phase number, or a negative value
575 >     * if terminated or argument is negative
576       * @throws InterruptedException if thread interrupted while waiting
577       */
578      public int awaitAdvanceInterruptibly(int phase)
# Line 590 | Line 595 | public class Phaser {
595       * returning immediately if the current phase of the barrier is not
596       * equal to the given phase value or this barrier is terminated.
597       *
598 <     * @param phase the phase on entry to this method
598 >     * @param phase an arrival phase number, or negative value if
599 >     * terminated; this argument is normally the value returned by a
600 >     * previous call to {@code arrive} or its variants
601       * @param timeout how long to wait before giving up, in units of
602       *        {@code unit}
603       * @param unit a {@code TimeUnit} determining how to interpret the
604       *        {@code timeout} parameter
605 <     * @return the current barrier phase number upon exit of
606 <     * this method, or a negative value if terminated or
600 <     * argument is negative
605 >     * @return the next arrival phase number, or a negative value
606 >     * if terminated or argument is negative
607       * @throws InterruptedException if thread interrupted while waiting
608       * @throws TimeoutException if timed out while waiting
609       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines