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.22 by jsr166, Sun Nov 14 20:44:11 2010 UTC vs.
Revision 1.23 by jsr166, Sun Nov 14 23:45:16 2010 UTC

# Line 649 | Line 649 | public class Phaser {
649      }
650  
651      /**
652 <     * Forces this barrier to enter termination state. Counts of
653 <     * arrived and registered parties are unaffected. If this phaser
654 <     * has a parent, it too is terminated. This method may be useful
655 <     * for coordinating recovery after one or more tasks encounter
656 <     * unexpected exceptions.
652 >     * Forces this barrier to enter termination state.  Counts of
653 >     * arrived and registered parties are unaffected.  If this phaser
654 >     * is a member of a tiered set of phasers, then all of the phasers
655 >     * in the set are terminated.  If this phaser is already
656 >     * terminated, this method has no effect.  This method may be
657 >     * useful for coordinating recovery after one or more tasks
658 >     * encounter unexpected exceptions.
659       */
660      public void forceTermination() {
661 <        Phaser r = root;    // force at root then reconcile
661 >        // Only need to change root state
662 >        final Phaser root = this.root;
663          long s;
664 <        while ((s = r.state) >= 0)
665 <            UNSAFE.compareAndSwapLong(r, stateOffset, s, s | TERMINATION_PHASE);
666 <        reconcileState();
667 <        releaseWaiters(0); // signal all threads
668 <        releaseWaiters(1);
664 >        while ((s = root.state) >= 0) {
665 >            if (UNSAFE.compareAndSwapLong(root, stateOffset,
666 >                                          s, s | TERMINATION_PHASE)) {
667 >                releaseWaiters(0); // signal all threads
668 >                releaseWaiters(1);
669 >                return;
670 >            }
671 >        }
672      }
673  
674      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines