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.14 by jsr166, Tue Jul 21 00:15:14 2009 UTC vs.
Revision 1.17 by jsr166, Thu Jul 23 19:25:45 2009 UTC

# Line 175 | Line 175 | import java.lang.reflect.*;
175   * parties result in IllegalStateExceptions. However, you can and
176   * should create tiered phasers to accommodate arbitrarily large sets
177   * of participants.
178 + *
179 + * @since 1.7
180 + * @author Doug Lea
181   */
182   public class Phaser {
183      /*
# Line 212 | Line 215 | public class Phaser {
215      }
216  
217      private static int partiesOf(long s) {
218 <        return ((int)s) >>> 16;
218 >        return ((int) s) >>> 16;
219      }
220  
221      private static int phaseOf(long s) {
222 <        return (int)(s >>> 32);
222 >        return (int) (s >>> 32);
223      }
224  
225      private static int arrivedOf(long s) {
# Line 224 | Line 227 | public class Phaser {
227      }
228  
229      private static long stateFor(int phase, int parties, int unarrived) {
230 <        return ((((long)phase) << 32) | (((long)parties) << 16) |
231 <                (long)unarrived);
230 >        return ((((long) phase) << 32) | (((long) parties) << 16) |
231 >                (long) unarrived);
232      }
233  
234      private static long trippedStateFor(int phase, int parties) {
235 <        long lp = (long)parties;
236 <        return (((long)phase) << 32) | (lp << 16) | lp;
235 >        long lp = (long) parties;
236 >        return (((long) phase) << 32) | (lp << 16) | lp;
237      }
238  
239      /**
# Line 953 | Line 956 | public class Phaser {
956  
957      private static long fieldOffset(String fieldName)
958              throws NoSuchFieldException {
959 <        return _unsafe.objectFieldOffset
959 >        return UNSAFE.objectFieldOffset
960              (Phaser.class.getDeclaredField(fieldName));
961      }
962  
963 <    static final Unsafe _unsafe;
963 >    static final Unsafe UNSAFE;
964      static final long stateOffset;
965  
966      static {
967          try {
968 <            _unsafe = getUnsafe();
968 >            UNSAFE = getUnsafe();
969              stateOffset = fieldOffset("state");
970          } catch (Throwable e) {
971              throw new RuntimeException("Could not initialize intrinsics", e);
# Line 970 | Line 973 | public class Phaser {
973      }
974  
975      final boolean casState(long cmp, long val) {
976 <        return _unsafe.compareAndSwapLong(this, stateOffset, cmp, val);
976 >        return UNSAFE.compareAndSwapLong(this, stateOffset, cmp, val);
977      }
978   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines