jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
equal
deleted
inserted
replaced
40 import java.security.AccessController; |
40 import java.security.AccessController; |
41 import java.security.PrivilegedActionException; |
41 import java.security.PrivilegedActionException; |
42 import java.security.PrivilegedExceptionAction; |
42 import java.security.PrivilegedExceptionAction; |
43 import java.util.function.BinaryOperator; |
43 import java.util.function.BinaryOperator; |
44 import java.util.function.UnaryOperator; |
44 import java.util.function.UnaryOperator; |
|
45 import jdk.internal.misc.Unsafe; |
45 import jdk.internal.reflect.CallerSensitive; |
46 import jdk.internal.reflect.CallerSensitive; |
46 import jdk.internal.reflect.Reflection; |
47 import jdk.internal.reflect.Reflection; |
47 |
48 |
48 /** |
49 /** |
49 * A reflection-based utility that enables atomic updates to |
50 * A reflection-based utility that enables atomic updates to |
166 * @since 1.6 |
167 * @since 1.6 |
167 */ |
168 */ |
168 public abstract void lazySet(T obj, V newValue); |
169 public abstract void lazySet(T obj, V newValue); |
169 |
170 |
170 /** |
171 /** |
171 * Gets the current value held in the field of the given object managed |
172 * Returns the current value held in the field of the given object |
172 * by this updater. |
173 * managed by this updater. |
173 * |
174 * |
174 * @param obj An object whose field to get |
175 * @param obj An object whose field to get |
175 * @return the current value |
176 * @return the current value |
176 */ |
177 */ |
177 public abstract V get(T obj); |
178 public abstract V get(T obj); |
282 return next; |
283 return next; |
283 } |
284 } |
284 |
285 |
285 private static final class AtomicReferenceFieldUpdaterImpl<T,V> |
286 private static final class AtomicReferenceFieldUpdaterImpl<T,V> |
286 extends AtomicReferenceFieldUpdater<T,V> { |
287 extends AtomicReferenceFieldUpdater<T,V> { |
287 private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe(); |
288 private static final Unsafe U = Unsafe.getUnsafe(); |
288 private final long offset; |
289 private final long offset; |
289 /** |
290 /** |
290 * if field is protected, the subclass constructing updater, else |
291 * if field is protected, the subclass constructing updater, else |
291 * the same as tclass |
292 * the same as tclass |
292 */ |
293 */ |