volatile long
fields of designated classes.
This class is designed for use in atomic data structures in which
several fields of the same node are independently subject to atomic
updates.
Note that the guarantees of the compareAndSet
method in this class are weaker than in other atomic classes.
Because this class cannot ensure that all uses of the field
are appropriate for purposes of atomic access, it can
guarantee atomicity only with respect to other invocations of
compareAndSet
and set
on the same updater.
Object arguments for parameters of type T
that are not
instances of the class passed to newUpdater
will result in
a ClassCastException
being thrown.
Modifier and Type | Class and Description |
---|---|
private static class |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
public final long | Returns: the updated valueAn object whose field to get and set obj, long the update value x, LongBinaryOperator a side-effect-free function of two arguments accumulatorFunction)Atomically updates (with memory effects as specified by |
public long | Returns: the updated valueAn object whose field to get and set obj, long the value to add delta)Atomically adds the given value to the current value of the field of the given object managed by this updater. |
public abstract boolean | Returns: true if successfulAn object whose field to conditionally set obj, long the expected value expect, long the new value update)Atomically sets the field of the given object managed by this updater
to the given updated value if the current value |
public long | Returns: the updated valueAn object whose field to get and set obj)Atomically decrements by one the current value of the field of the given object managed by this updater. |
public abstract long | Returns: the current valueAn object whose field to get obj)Returns the current value held in the field of the given object managed by this updater. |
public final long | Returns: the previous valueAn object whose field to get and set obj, long the update value x, LongBinaryOperator a side-effect-free function of two arguments accumulatorFunction)Atomically updates (with memory effects as specified by |
public long | Returns: the previous valueAn object whose field to get and set obj, long the value to add delta)Atomically adds the given value to the current value of the field of the given object managed by this updater. |
public long | Returns: the previous valueAn object whose field to get and set obj)Atomically decrements by one the current value of the field of the given object managed by this updater. |
public long | Returns: the previous valueAn object whose field to get and set obj)Atomically increments by one the current value of the field of the given object managed by this updater. |
public long | Returns: the previous valueAn object whose field to get and set obj, long the new value newValue)Atomically sets the field of the given object managed by this updater to the given value and returns the old value. |
public final long | Returns: the previous valueAn object whose field to get and set obj, LongUnaryOperator a side-effect-free function updateFunction)Atomically updates (with memory effects as specified by |
public long | Returns: the updated valueAn object whose field to get and set obj)Atomically increments by one the current value of the field of the given object managed by this updater. |
pack-priv static boolean | isAncestor(ClassLoader first, ClassLoader second)
Returns true if the second classloader can be found in the first classloader's delegation chain. |
pack-priv static boolean | isSamePackage(Class<?> class1, Class<?> class2)
Returns true if the two classes have the same class loader and package qualifier |
public abstract void | lazySet(T
An object whose field to set obj, long the new value newValue)Eventually sets the field of the given object managed by this updater to the given updated value. |
public static < the type of instances of tclass U> AtomicLongFieldUpdater | Returns: the updaterthe class of the objects holding the field tclass, String the name of the field to be updated fieldName)Creates and returns an updater for objects with the given field. |
public abstract void | set(T
An object whose field to set obj, long the new value newValue)Sets the field of the given object managed by this updater to the given updated value. |
public final long | Returns: the updated valueAn object whose field to get and set obj, LongUnaryOperator a side-effect-free function updateFunction)Atomically updates (with memory effects as specified by |
public abstract boolean | Returns: true if successfulAn object whose field to conditionally set obj, long the expected value expect, long the new value update)Atomically sets the field of the given object managed by this updater
to the given updated value if the current value |
AtomicLongFieldUpdater | back to summary |
---|---|
protected AtomicLongFieldUpdater() Protected do-nothing constructor for use by subclasses. |
accumulateAndGet | back to summary |
---|---|
public final long accumulateAndGet(T obj, long x, LongBinaryOperator accumulatorFunction) Atomically updates (with memory effects as specified by
|
addAndGet | back to summary |
---|---|
public long addAndGet(T obj, long delta) Atomically adds the given value to the current value of the field of the given object managed by this updater.
|
compareAndSet | back to summary |
---|---|
public abstract boolean compareAndSet(T obj, long expect, long update) Atomically sets the field of the given object managed by this updater
to the given updated value if the current value
|
decrementAndGet | back to summary |
---|---|
public long decrementAndGet(T obj) Atomically decrements by one the current value of the field of the given object managed by this updater.
|
get | back to summary |
---|---|
public abstract long get(T obj) Returns the current value held in the field of the given object managed by this updater.
|
getAndAccumulate | back to summary |
---|---|
public final long getAndAccumulate(T obj, long x, LongBinaryOperator accumulatorFunction) Atomically updates (with memory effects as specified by
|
getAndAdd | back to summary |
---|---|
public long getAndAdd(T obj, long delta) Atomically adds the given value to the current value of the field of the given object managed by this updater.
|
getAndDecrement | back to summary |
---|---|
public long getAndDecrement(T obj) Atomically decrements by one the current value of the field of the given object managed by this updater.
|
getAndIncrement | back to summary |
---|---|
public long getAndIncrement(T obj) Atomically increments by one the current value of the field of the given object managed by this updater.
|
getAndSet | back to summary |
---|---|
public long getAndSet(T obj, long newValue) Atomically sets the field of the given object managed by this updater to the given value and returns the old value.
|
getAndUpdate | back to summary |
---|---|
public final long getAndUpdate(T obj, LongUnaryOperator updateFunction) Atomically updates (with memory effects as specified by
|
incrementAndGet | back to summary |
---|---|
public long incrementAndGet(T obj) Atomically increments by one the current value of the field of the given object managed by this updater.
|
isAncestor | back to summary |
---|---|
pack-priv static boolean isAncestor(ClassLoader first, ClassLoader second) Returns true if the second classloader can be found in the first classloader's delegation chain. Equivalent to the inaccessible: first.isAncestor(second). |
isSamePackage | back to summary |
---|---|
pack-priv static boolean isSamePackage(Class<?> class1, Class<?> class2) Returns true if the two classes have the same class loader and package qualifier |
lazySet | back to summary |
---|---|
public abstract void lazySet(T obj, long newValue) Eventually sets the field of the given object managed by this updater to the given updated value.
|
newUpdater | back to summary |
---|---|
public static <U> AtomicLongFieldUpdater Creates and returns an updater for objects with the given field. The Class argument is needed to check that reflective types and generic types match.
|
set | back to summary |
---|---|
public abstract void set(T obj, long newValue) Sets the field of the given object managed by this updater to the
given updated value. This operation is guaranteed to act as a volatile
store with respect to subsequent invocations of
|
updateAndGet | back to summary |
---|---|
public final long updateAndGet(T obj, LongUnaryOperator updateFunction) Atomically updates (with memory effects as specified by
|
weakCompareAndSet | back to summary |
---|---|
public abstract boolean weakCompareAndSet(T obj, long expect, long update) Atomically sets the field of the given object managed by this updater
to the given updated value if the current value This operation may fail spuriously and does not provide
ordering guarantees, so is only rarely an appropriate
alternative to
|
Modifier and Type | Field and Description |
---|---|
private final Class | cclass
if field is protected, the subclass constructing updater, else the same as tclass |
private final long | |
private final Class | tclass
class holding the field |
private static final Unsafe |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
private final void | |
public final long | addAndGet(T
An object whose field to get and set obj, long the value to add delta)Overrides java. Atomically adds the given value to the current value of the field of the given object managed by this updater. |
public final boolean | compareAndSet(T
An object whose field to conditionally set obj, long the expected value expect, long the new value update)Implements abstract java. Atomically sets the field of the given object managed by this updater
to the given updated value if the current value |
public final long | decrementAndGet(T
An object whose field to get and set obj)Overrides java. Atomically decrements by one the current value of the field of the given object managed by this updater. |
public final long | get(T
An object whose field to get obj)Implements abstract java. Returns the current value held in the field of the given object managed by this updater. |
public final long | getAndAdd(T
An object whose field to get and set obj, long the value to add delta)Overrides java. Atomically adds the given value to the current value of the field of the given object managed by this updater. |
public final long | getAndDecrement(T
An object whose field to get and set obj)Overrides java. Atomically decrements by one the current value of the field of the given object managed by this updater. |
public final long | getAndIncrement(T
An object whose field to get and set obj)Overrides java. Atomically increments by one the current value of the field of the given object managed by this updater. |
public final long | getAndSet(T
An object whose field to get and set obj, long the new value newValue)Overrides java. Atomically sets the field of the given object managed by this updater to the given value and returns the old value. |
public final long | incrementAndGet(T
An object whose field to get and set obj)Overrides java. Atomically increments by one the current value of the field of the given object managed by this updater. |
public final void | lazySet(T
An object whose field to set obj, long the new value newValue)Implements abstract java. Eventually sets the field of the given object managed by this updater to the given updated value. |
public final void | set(T
An object whose field to set obj, long the new value newValue)Implements abstract java. Sets the field of the given object managed by this updater to the given updated value. |
private final void | throwAccessCheckException(T obj)
Throws access exception if accessCheck failed due to protected access, else ClassCastException. |
public final boolean | weakCompareAndSet(T
An object whose field to conditionally set obj, long the expected value expect, long the new value update)Implements abstract java. Atomically sets the field of the given object managed by this updater
to the given updated value if the current value |
cclass | back to summary |
---|---|
private final Class<?> cclass if field is protected, the subclass constructing updater, else the same as tclass |
offset | back to summary |
---|---|
private final long offset |
tclass | back to summary |
---|---|
private final Class<T> tclass class holding the field |
U | back to summary |
---|---|
private static final Unsafe U |
CASUpdater | back to summary |
---|---|
pack-priv CASUpdater(final Class<T> tclass, final String fieldName, final Class<?> caller)
|
accessCheck | back to summary |
---|---|
private final void accessCheck(T obj) Checks that target argument is instance of cclass. On failure, throws cause. |
addAndGet | back to summary |
---|---|
public final long addAndGet(T obj, long delta) Overrides java. Doc from java. Atomically adds the given value to the current value of the field of the given object managed by this updater.
|
compareAndSet | back to summary |
---|---|
public final boolean compareAndSet(T obj, long expect, long update) Implements abstract java. Doc from java. Atomically sets the field of the given object managed by this updater
to the given updated value if the current value
|
decrementAndGet | back to summary |
---|---|
public final long decrementAndGet(T obj) Overrides java. Doc from java. Atomically decrements by one the current value of the field of the given object managed by this updater.
|
get | back to summary |
---|---|
public final long get(T obj) Implements abstract java. Doc from java. Returns the current value held in the field of the given object managed by this updater.
|
getAndAdd | back to summary |
---|---|
public final long getAndAdd(T obj, long delta) Overrides java. Doc from java. Atomically adds the given value to the current value of the field of the given object managed by this updater.
|
getAndDecrement | back to summary |
---|---|
public final long getAndDecrement(T obj) Overrides java. Doc from java. Atomically decrements by one the current value of the field of the given object managed by this updater.
|
getAndIncrement | back to summary |
---|---|
public final long getAndIncrement(T obj) Overrides java. Doc from java. Atomically increments by one the current value of the field of the given object managed by this updater.
|
getAndSet | back to summary |
---|---|
public final long getAndSet(T obj, long newValue) Overrides java. Doc from java. Atomically sets the field of the given object managed by this updater to the given value and returns the old value.
|
incrementAndGet | back to summary |
---|---|
public final long incrementAndGet(T obj) Overrides java. Doc from java. Atomically increments by one the current value of the field of the given object managed by this updater.
|
lazySet | back to summary |
---|---|
public final void lazySet(T obj, long newValue) Implements abstract java. Doc from java. Eventually sets the field of the given object managed by this updater to the given updated value.
|
set | back to summary |
---|---|
public final void set(T obj, long newValue) Implements abstract java. Doc from java. Sets the field of the given object managed by this updater to the
given updated value. This operation is guaranteed to act as a volatile
store with respect to subsequent invocations of
|
throwAccessCheckException | back to summary |
---|---|
private final void throwAccessCheckException(T obj) Throws access exception if accessCheck failed due to protected access, else ClassCastException. |
weakCompareAndSet | back to summary |
---|---|
public final boolean weakCompareAndSet(T obj, long expect, long update) Implements abstract java. Doc from java. Atomically sets the field of the given object managed by this updater
to the given updated value if the current value This operation may fail spuriously and does not provide
ordering guarantees, so is only rarely an appropriate
alternative to
|