Class LocalAtomicReference<V>
- Type Parameters:
V- the type of object referred to by this reference
- All Implemented Interfaces:
AtomicReference<V>
AtomicReference
interface, that simply wraps java.util.concurrent.atomic.AtomicReference instance.- Author:
- Aleks Seovic 2020.12.08
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.oracle.coherence.concurrent.atomic.AtomicReference
AtomicReference.Serializer<V> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLocalAtomicReference(AtomicReference<V> value) ConstructLocalAtomicReference<V>instance.protectedLocalAtomicReference(V value) ConstructLocalAtomicReference<V>instance. -
Method Summary
Modifier and TypeMethodDescriptionaccumulateAndGet(V x, Remote.BinaryOperator<V> accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.accumulateAndGet(V x, BinaryOperator<V> accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.async()Return non-blocking API for this atomic reference.compareAndExchange(V expectedValue, V newValue) Atomically sets the value tonewValueif the current value, referred to as the witness value, is equal to the== expectedValue.booleancompareAndSet(V expectedValue, V newValue) Atomically sets the value tonewValueif the current value is equal to theexpectedValue.get()Returns the current value.getAndAccumulate(V x, Remote.BinaryOperator<V> accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.getAndAccumulate(V x, BinaryOperator<V> accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.Atomically sets the value tonewValueand returns the old value.getAndUpdate(Remote.UnaryOperator<V> updateFunction) Atomically updates the current value with the results of applying the given function, returning the previous value.getAndUpdate(UnaryOperator<V> updateFunction) Atomically updates the current value with the results of applying the given function, returning the previous value.voidSets the value tonewValue.toString()updateAndGet(Remote.UnaryOperator<V> updateFunction) Atomically updates the current value with the results of applying the given function, returning the updated value.updateAndGet(UnaryOperator<V> updateFunction) Atomically updates the current value with the results of applying the given function, returning the updated value.
-
Constructor Details
-
LocalAtomicReference
ConstructLocalAtomicReference<V>instance.- Parameters:
value- initial value
-
LocalAtomicReference
ConstructLocalAtomicReference<V>instance.- Parameters:
value- wrapped value
-
-
Method Details
-
async
Description copied from interface:AtomicReferenceReturn non-blocking API for this atomic reference.- Specified by:
asyncin interfaceAtomicReference<V>- Returns:
- non-blocking API for this atomic reference
-
get
Description copied from interface:AtomicReferenceReturns the current value.- Specified by:
getin interfaceAtomicReference<V>- Returns:
- the current value
-
set
Description copied from interface:AtomicReferenceSets the value tonewValue.- Specified by:
setin interfaceAtomicReference<V>- Parameters:
newValue- the new value
-
getAndSet
Description copied from interface:AtomicReferenceAtomically sets the value tonewValueand returns the old value.- Specified by:
getAndSetin interfaceAtomicReference<V>- Parameters:
newValue- the new value- Returns:
- the previous value
-
compareAndSet
Description copied from interface:AtomicReferenceAtomically sets the value tonewValueif the current value is equal to theexpectedValue.- Specified by:
compareAndSetin interfaceAtomicReference<V>- Parameters:
expectedValue- the expected valuenewValue- the new value- Returns:
trueif successful. False return indicates that the actual value was not equal to the expected value.
-
getAndUpdate
Description copied from interface:AtomicReferenceAtomically updates 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.- Specified by:
getAndUpdatein interfaceAtomicReference<V>- Parameters:
updateFunction- a side-effect-free function- Returns:
- the previous value
-
getAndUpdate
Description copied from interface:AtomicReferenceAtomically updates 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.- Specified by:
getAndUpdatein interfaceAtomicReference<V>- Parameters:
updateFunction- a side-effect-free function- Returns:
- the previous value
-
updateAndGet
Description copied from interface:AtomicReferenceAtomically updates 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.- Specified by:
updateAndGetin interfaceAtomicReference<V>- Parameters:
updateFunction- a side-effect-free function- Returns:
- the updated value
-
updateAndGet
Description copied from interface:AtomicReferenceAtomically updates 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.- Specified by:
updateAndGetin interfaceAtomicReference<V>- Parameters:
updateFunction- a side-effect-free function- Returns:
- the updated value
-
getAndAccumulate
Description copied from interface:AtomicReferenceAtomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.The function should beside-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.
- Specified by:
getAndAccumulatein interfaceAtomicReference<V>- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the previous value
-
getAndAccumulate
Description copied from interface:AtomicReferenceAtomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.The function should beside-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.
- Specified by:
getAndAccumulatein interfaceAtomicReference<V>- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the previous value
-
accumulateAndGet
Description copied from interface:AtomicReferenceAtomically updates 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.
- Specified by:
accumulateAndGetin interfaceAtomicReference<V>- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the updated value
-
accumulateAndGet
Description copied from interface:AtomicReferenceAtomically updates 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.
- Specified by:
accumulateAndGetin interfaceAtomicReference<V>- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the updated value
-
compareAndExchange
Description copied from interface:AtomicReferenceAtomically sets the value tonewValueif the current value, referred to as the witness value, is equal to the== expectedValue.- Specified by:
compareAndExchangein interfaceAtomicReference<V>- Parameters:
expectedValue- the expected valuenewValue- the new value- Returns:
- the witness value, which will be the same as the expected value if successful
-
toString
-