V - value typepublic class DefaultAtomicValue<V> extends Synchronous<AsyncAtomicValue<V>> implements AtomicValue<V>
AtomicValue backed by a AsyncAtomicValue.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
DefaultAtomicValue(AsyncAtomicValue<V> asyncValue,
long operationTimeoutMillis) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(AtomicValueEventListener<V> listener)
Registers the specified listener to be notified whenever the atomic value is updated.
|
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.
|
V |
get()
Gets the current value.
|
V |
getAndSet(V value)
Atomically sets to the given value and returns the old value.
|
void |
removeListener(AtomicValueEventListener<V> listener)
Unregisters the specified listener such that it will no longer
receive atomic value update notifications.
|
void |
set(V value)
Sets to the given value.
|
destroy, name, primitiveTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprimitiveTypeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic DefaultAtomicValue(AsyncAtomicValue<V> asyncValue, long operationTimeoutMillis)
public boolean compareAndSet(V expect, V update)
AtomicValueIMPORTANT: Equality is based on the equality of the serialized byte[] representations.
compareAndSet in interface AtomicValue<V>expect - the expected valueupdate - the new valuepublic V get()
AtomicValueget in interface AtomicValue<V>public V getAndSet(V value)
AtomicValuegetAndSet in interface AtomicValue<V>value - the new valuepublic void set(V value)
AtomicValueset in interface AtomicValue<V>value - new valuepublic void addListener(AtomicValueEventListener<V> listener)
AtomicValueaddListener in interface AtomicValue<V>listener - listener to notify about eventspublic void removeListener(AtomicValueEventListener<V> listener)
AtomicValueremoveListener in interface AtomicValue<V>listener - listener to unregister