V - value typepublic interface AsyncAtomicValue<V> extends AsyncPrimitive
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.
|
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.
|
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.
|
default AtomicValue<V> |
sync()
Returns a synchronous wrapper around the asynchronous primitive.
|
AtomicValue<V> |
sync(Duration operationTimeout)
Returns a synchronous wrapper around the asynchronous primitive.
|
close, deleteaddStateChangeListener, name, protocol, removeStateChangeListener, typeCompletableFuture<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 falseCompletableFuture<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> sync()
AsyncPrimitivesync in interface AsyncPrimitiveAtomicValue<V> sync(Duration operationTimeout)
AsyncPrimitivesync in interface AsyncPrimitiveoperationTimeout - the synchronous operation timeoutCopyright © 2013–2018. All rights reserved.