--- jsr166/src/jsr166y/Phaser.java 2009/07/21 00:15:14 1.14 +++ jsr166/src/jsr166y/Phaser.java 2009/07/23 19:25:45 1.17 @@ -175,6 +175,9 @@ import java.lang.reflect.*; * parties result in IllegalStateExceptions. However, you can and * should create tiered phasers to accommodate arbitrarily large sets * of participants. + * + * @since 1.7 + * @author Doug Lea */ public class Phaser { /* @@ -212,11 +215,11 @@ public class Phaser { } private static int partiesOf(long s) { - return ((int)s) >>> 16; + return ((int) s) >>> 16; } private static int phaseOf(long s) { - return (int)(s >>> 32); + return (int) (s >>> 32); } private static int arrivedOf(long s) { @@ -224,13 +227,13 @@ public class Phaser { } private static long stateFor(int phase, int parties, int unarrived) { - return ((((long)phase) << 32) | (((long)parties) << 16) | - (long)unarrived); + return ((((long) phase) << 32) | (((long) parties) << 16) | + (long) unarrived); } private static long trippedStateFor(int phase, int parties) { - long lp = (long)parties; - return (((long)phase) << 32) | (lp << 16) | lp; + long lp = (long) parties; + return (((long) phase) << 32) | (lp << 16) | lp; } /** @@ -953,16 +956,16 @@ public class Phaser { private static long fieldOffset(String fieldName) throws NoSuchFieldException { - return _unsafe.objectFieldOffset + return UNSAFE.objectFieldOffset (Phaser.class.getDeclaredField(fieldName)); } - static final Unsafe _unsafe; + static final Unsafe UNSAFE; static final long stateOffset; static { try { - _unsafe = getUnsafe(); + UNSAFE = getUnsafe(); stateOffset = fieldOffset("state"); } catch (Throwable e) { throw new RuntimeException("Could not initialize intrinsics", e); @@ -970,6 +973,6 @@ public class Phaser { } final boolean casState(long cmp, long val) { - return _unsafe.compareAndSwapLong(this, stateOffset, cmp, val); + return UNSAFE.compareAndSwapLong(this, stateOffset, cmp, val); } }