src/java.base/share/classes/java/util/concurrent/Phaser.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke


1120                 (nanos <= 0L || (nanos = deadline - System.nanoTime()) <= 0L)) {
1121                 thread = null;
1122                 return true;
1123             }
1124             return false;
1125         }
1126 
1127         public boolean block() {
1128             while (!isReleasable()) {
1129                 if (timed)
1130                     LockSupport.parkNanos(this, nanos);
1131                 else
1132                     LockSupport.park(this);
1133             }
1134             return true;
1135         }
1136     }
1137 
1138     // Unsafe mechanics
1139 
1140     private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
1141     private static final long STATE;
1142     static {
1143         try {
1144             STATE = U.objectFieldOffset
1145                 (Phaser.class.getDeclaredField("state"));
1146         } catch (ReflectiveOperationException e) {
1147             throw new Error(e);
1148         }
1149 
1150         // Reduce the risk of rare disastrous classloading in first call to
1151         // LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773
1152         Class<?> ensureLoaded = LockSupport.class;
1153     }
1154 }


1120                 (nanos <= 0L || (nanos = deadline - System.nanoTime()) <= 0L)) {
1121                 thread = null;
1122                 return true;
1123             }
1124             return false;
1125         }
1126 
1127         public boolean block() {
1128             while (!isReleasable()) {
1129                 if (timed)
1130                     LockSupport.parkNanos(this, nanos);
1131                 else
1132                     LockSupport.park(this);
1133             }
1134             return true;
1135         }
1136     }
1137 
1138     // Unsafe mechanics
1139 
1140     private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
1141     private static final long STATE;
1142     static {
1143         try {
1144             STATE = U.objectFieldOffset
1145                 (Phaser.class.getDeclaredField("state"));
1146         } catch (ReflectiveOperationException e) {
1147             throw new Error(e);
1148         }
1149 
1150         // Reduce the risk of rare disastrous classloading in first call to
1151         // LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773
1152         Class<?> ensureLoaded = LockSupport.class;
1153     }
1154 }