V - value typepublic class DefaultAsyncAtomicValue<V> extends Object implements AsyncAtomicValue<V>
AsyncAtomicValue.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
DefaultAsyncAtomicValue(String name,
Serializer serializer,
AsyncConsistentMap<String,byte[]> backingMap) |
| 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<Void> |
destroy()
Purges state associated with this primitive.
|
CompletableFuture<V> |
get()
Gets the current value.
|
CompletableFuture<V> |
getAndSet(V value)
Atomically sets to the given value and returns the old value.
|
String |
name()
Returns the name of this 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasAtomicValue, asAtomicValue, primitiveTypeaddStatusChangeListener, applicationId, removeStatusChangeListener, statusChangeListenerspublic DefaultAsyncAtomicValue(String name, Serializer serializer, AsyncConsistentMap<String,byte[]> backingMap)
public String name()
DistributedPrimitivename in interface DistributedPrimitivepublic CompletableFuture<Void> destroy()
DistributedPrimitiveImplementations can override and provide appropriate clean up logic for purging any state state associated with the primitive. Whether modifications made within the destroy method have local or global visibility is left unspecified.
destroy in interface DistributedPrimitiveCompletableFuture that is completed when the operation completespublic 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