V
- value typepublic interface AsyncAtomicValue<V> extends DistributedPrimitive
DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS
Modifier and Type | Method and Description |
---|---|
CompletableFuture<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. |
CompletableFuture<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.
|
CompletableFuture<V> |
get()
Gets the current value.
|
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.
|
CompletableFuture<Void> |
removeListener(AtomicValueEventListener<V> listener)
Unregisters the specified listener such that it will no longer
receive atomic value update notifications.
|
CompletableFuture<Void> |
set(V value)
Sets to the given value.
|
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
default DistributedPrimitive.Type primitiveType()
DistributedPrimitive
primitiveType
in interface DistributedPrimitive
CompletableFuture<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 false
CompletableFuture<V> get()
CompletableFuture<V> getAndSet(V value)
value
- the new valueCompletableFuture<Void> set(V value)
value
- value to setCompletableFuture<Void> addListener(AtomicValueEventListener<V> listener)
listener
- listener to notify about eventsCompletableFuture<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