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 |
|
/** |