Tanzu GemFire Distributed Types Java API Reference
Interface DAtomicReference<V>
- All Superinterfaces:
DType
A distributed and highly-available implementation of
AtomicReferences.-
Method Summary
Modifier and TypeMethodDescriptionaccumulateAndGet(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.booleancompareAndSet(V expect, V update) Atomically sets the value to the given updated value if the current value == the expected value.get()Gets the current 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 to the given value and returns the old value.getAndUpdate(UnaryOperator<V> updateFunction) Atomically updates the current value with the results of applying the given function, returning the previous value.voidSets to the given value.updateAndGet(UnaryOperator<V> updateFunction) Atomically updates the current value with the results of applying the given function, returning the updated value.
-
Method Details
-
accumulateAndGet
Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.Note that the provided function will also need to be declared as
Serializable:ref.accumulateAndGet(1L, (Serializable & BinaryOperator<Long>) Long::sum);
- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the updated value
-
compareAndSet
Atomically sets the value to the given updated value if the current value == the expected value.- Parameters:
expect- the expected valueupdate- the new value- Returns:
- true if successful
-
get
V get()Gets the current value.- Returns:
- the current value
-
getAndAccumulate
Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.Note that the provided function will also need to be declared as
Serializable:ref.getAndAccumulate(1L, (Serializable & BinaryOperator<Long>) Long::sum);
- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the previous value
-
getAndUpdate
Atomically updates the current value with the results of applying the given function, returning the previous value.Note that the provided function will also need to be declared as
Serializable:ref.getAndUpdate((Serializable & UnaryOperator<Long>) x -> x * 7)
- Parameters:
updateFunction- a side-effect-free function- Returns:
- the previous value
-
getAndSet
Atomically sets to the given value and returns the old value.- Parameters:
newValue- the value to set- Returns:
- the previous value
-
set
Sets to the given value.- Parameters:
newValue- the value to set
-
updateAndGet
Atomically updates the current value with the results of applying the given function, returning the updated value.Note that the provided function will also need to be declared as
Serializable:ref.updateAndGet((Serializable & UnaryOperator<Long>) x -> x * 7)
- Parameters:
updateFunction- a side-effect-free function- Returns:
- the updated value
-