V - value typepublic interface AsyncAtomicValue<V> extends DistributedPrimitive
All methods of this interface return a future immediately
after a successful invocation. The operation itself is executed asynchronous and
the returned future will be completed when the
operation finishes.
DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<java.lang.Void> |
addListener(AtomicValueEventListener<V> listener)
Registers the specified listener to be notified whenever the atomic value is updated.
|
default AtomicValue<V> |
asAtomicValue()
Returns a new
AtomicValue that is backed by this instance and with a default operation timeout. |
default AtomicValue<V> |
asAtomicValue(long timeoutMillis)
Returns a new
AtomicValue that is backed by this instance. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
compareAndSet(V expect,
V update)
Atomically sets the value to the given updated value if the current value is equal to the expected value.
|
java.util.concurrent.CompletableFuture<V> |
get()
Gets the current value.
|
java.util.concurrent.CompletableFuture<V> |
getAndSet(V value)
Atomically sets to the given value and returns the old value.
|
default DistributedPrimitive.Type |
primitiveType()
Returns the type of primitive.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
removeListener(AtomicValueEventListener<V> listener)
Unregisters the specified listener such that it will no longer
receive atomic value update notifications.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
set(V value)
Sets to the given value.
|
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenersdefault DistributedPrimitive.Type primitiveType()
DistributedPrimitiveprimitiveType in interface DistributedPrimitivejava.util.concurrent.CompletableFuture<java.lang.Boolean> compareAndSet(V expect, V update)
IMPORTANT: Equality is based on the equality of the serialized {code byte[]} representations.
expect - the expected valueupdate - the new valuetrue if update was successful. Otherwise future
will be completed with a value of falsejava.util.concurrent.CompletableFuture<V> get()
java.util.concurrent.CompletableFuture<V> getAndSet(V value)
value - the new valuejava.util.concurrent.CompletableFuture<java.lang.Void> set(V value)
value - value to setjava.util.concurrent.CompletableFuture<java.lang.Void> addListener(AtomicValueEventListener<V> listener)
listener - listener to notify about eventsjava.util.concurrent.CompletableFuture<java.lang.Void> removeListener(AtomicValueEventListener<V> listener)
listener - listener to unregisterdefault AtomicValue<V> asAtomicValue(long timeoutMillis)
AtomicValue that is backed by this instance.timeoutMillis - timeout duration for the returned ConsistentMap operationsAtomicValue instancedefault AtomicValue<V> asAtomicValue()
AtomicValue that is backed by this instance and with a default operation timeout.AtomicValue instance