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.69 by jsr166, Mon Oct 10 06:06:21 2011 UTC vs.
Revision 1.70 by jsr166, Thu Oct 13 00:22:19 2011 UTC

# Line 426 | Line 426 | public class Phaser {
426              else {
427                  synchronized (this) {               // 1st sub registration
428                      if (state == s) {               // recheck under lock
429 <                        parent.doRegister(1);
430 <                        do {                        // force current phase
429 >                        phase = parent.doRegister(1);
430 >                        if (phase < 0)
431 >                            break;
432 >                        // finish registration whenever parent registration
433 >                        // succeeded, even when racing with termination,
434 >                        // since these are part of the same "transaction".
435 >                        while (!UNSAFE.compareAndSwapLong
436 >                               (this, stateOffset, s,
437 >                                ((long)phase << PHASE_SHIFT) | adjust)) {
438 >                            s = state;
439                              phase = (int)(root.state >>> PHASE_SHIFT);
440 <                            // assert phase < 0 || (int)state == EMPTY;
441 <                        } while (!UNSAFE.compareAndSwapLong
434 <                                 (this, stateOffset, state,
435 <                                  ((long)phase << PHASE_SHIFT) | adjust));
440 >                            // assert (int)s == EMPTY;
441 >                        }
442                          break;
443                      }
444                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines