8181104: Fix specs for updateAndGet and related methods
Reviewed-by: martin, psandoz, dholmes, chegar
This commit is contained in:
parent
296439bb2c
commit
a981ce3262
@ -110,6 +110,20 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
|
||||
* boolean r = avh.compareAndSet(sa, 10, "expected", "new");
|
||||
* }</pre>
|
||||
*
|
||||
* <p>Access modes control atomicity and consistency properties.
|
||||
* <em>Plain</em> read ({@code get}) and write ({@code set})
|
||||
* accesses are guaranteed to be bitwise atomic only for references
|
||||
* and for primitive values of at most 32 bits, and impose no observable
|
||||
* ordering constraints with respect to threads other than the
|
||||
* executing thread. <em>Opaque</em> operations are bitwise atomic and
|
||||
* coherently ordered with respect to accesses to the same variable.
|
||||
* In addition to obeying Opaque properties, <em>Acquire</em> mode
|
||||
* reads and their subsequent accesses are ordered after matching
|
||||
* <em>Release</em> mode writes and their previous accesses. In
|
||||
* addition to obeying Acquire and Release properties, all
|
||||
* <em>Volatile</em> operations are totally ordered with respect to
|
||||
* each other.
|
||||
*
|
||||
* <p>Access modes are grouped into the following categories:
|
||||
* <ul>
|
||||
* <li>read access modes that get the value of a variable under specified
|
||||
|
@ -249,7 +249,8 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
@ -270,7 +271,8 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
@ -291,13 +293,14 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
@ -317,13 +320,14 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
@ -260,10 +260,12 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* previous value. The function should be side-effect-free, since
|
||||
* it may be re-applied when attempted updates fail due to
|
||||
* contention among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -282,10 +284,12 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* updated value. The function should be side-effect-free, since it
|
||||
* may be re-applied when attempted updates fail due to contention
|
||||
* among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -304,10 +308,11 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the previous value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
@ -332,10 +337,11 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the updated value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
@ -46,6 +46,7 @@ import java.util.function.IntUnaryOperator;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.reflect.CallerSensitive;
|
||||
import jdk.internal.reflect.Reflection;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A reflection-based utility that enables atomic updates to
|
||||
@ -275,10 +276,12 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the previous
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -295,10 +298,12 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the updated
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -315,13 +320,14 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the previous value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
@ -340,13 +346,14 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the updated value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
@ -118,8 +118,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public final void set(long newValue) {
|
||||
// Use putLongVolatile instead of ordinary volatile store when
|
||||
// using compareAndSetLong, for sake of some 32bit systems.
|
||||
// See JDK-8180620: Clarify VarHandle mixed-access subtleties
|
||||
U.putLongVolatile(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
@ -265,7 +264,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
@ -286,7 +286,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
@ -307,13 +308,14 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
@ -333,13 +335,14 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
@ -260,10 +260,12 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* previous value. The function should be side-effect-free, since
|
||||
* it may be re-applied when attempted updates fail due to
|
||||
* contention among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -282,10 +284,12 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* updated value. The function should be side-effect-free, since it
|
||||
* may be re-applied when attempted updates fail due to contention
|
||||
* among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -304,10 +308,11 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the previous value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
@ -332,10 +337,11 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the updated value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
@ -46,6 +46,7 @@ import java.util.function.LongUnaryOperator;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.reflect.CallerSensitive;
|
||||
import jdk.internal.reflect.Reflection;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A reflection-based utility that enables atomic updates to
|
||||
@ -278,10 +279,12 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the previous
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -298,10 +301,12 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the updated
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -318,13 +323,14 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the previous value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
@ -343,13 +349,14 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the updated value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
@ -170,7 +170,8 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
@ -191,7 +192,8 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
@ -212,13 +214,14 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
@ -238,13 +241,14 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
@ -190,10 +190,12 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* previous value. The function should be side-effect-free, since
|
||||
* it may be re-applied when attempted updates fail due to
|
||||
* contention among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -212,10 +214,12 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* updated value. The function should be side-effect-free, since it
|
||||
* may be re-applied when attempted updates fail due to contention
|
||||
* among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -234,10 +238,11 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the previous value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
@ -262,10 +267,11 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the updated value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
@ -46,6 +46,7 @@ import java.util.function.UnaryOperator;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.reflect.CallerSensitive;
|
||||
import jdk.internal.reflect.Reflection;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A reflection-based utility that enables atomic updates to
|
||||
@ -199,10 +200,12 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the previous
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -219,10 +222,12 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the updated
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
@ -239,13 +244,14 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the previous value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
@ -264,13 +270,14 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the updated value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
Loading…
Reference in New Issue
Block a user