public class ExecutingAsyncAtomicValue<V> extends ExecutingDistributedPrimitive implements AsyncAtomicValue<V>
AsyncAtomicValue that executes asynchronous callbacks on a user provided
Executor.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
ExecutingAsyncAtomicValue(AsyncAtomicValue<V> delegateValue,
Executor orderedExecutor,
Executor threadPoolExecutor) |
| 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.
|
addStatusChangeListener, asyncFuture, destroy, removeStatusChangeListenerapplicationId, equals, hashCode, name, primitiveType, statusChangeListeners, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasAtomicValue, asAtomicValue, primitiveTypeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic ExecutingAsyncAtomicValue(AsyncAtomicValue<V> delegateValue, Executor orderedExecutor, Executor threadPoolExecutor)
public CompletableFuture<Boolean> compareAndSet(V expect, V update)
AsyncAtomicValueIMPORTANT: Equality is based on the equality of the serialized {code byte[]} representations.
compareAndSet in interface AsyncAtomicValue<V>expect - the expected valueupdate - the new valuetrue if update was successful. Otherwise future
will be completed with a value of falsepublic CompletableFuture<V> get()
AsyncAtomicValueget in interface AsyncAtomicValue<V>public CompletableFuture<V> getAndSet(V value)
AsyncAtomicValuegetAndSet in interface AsyncAtomicValue<V>value - the new valuepublic CompletableFuture<Void> set(V value)
AsyncAtomicValueset in interface AsyncAtomicValue<V>value - value to setpublic CompletableFuture<Void> addListener(AtomicValueEventListener<V> listener)
AsyncAtomicValueaddListener in interface AsyncAtomicValue<V>listener - listener to notify about eventspublic CompletableFuture<Void> removeListener(AtomicValueEventListener<V> listener)
AsyncAtomicValueremoveListener in interface AsyncAtomicValue<V>listener - listener to unregister