Package org.onosproject.store.service
Interface AsyncAtomicValue<V>
- 
- Type Parameters:
 V- value type
- All Superinterfaces:
 DistributedPrimitive
public interface AsyncAtomicValue<V> extends DistributedPrimitive
Distributed version of java.util.concurrent.atomic.AtomicReference.All methods of this interface return a
futureimmediately after a successful invocation. The operation itself is executed asynchronous and the returned future will becompletedwhen the operation finishes. 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from interface org.onosproject.store.service.DistributedPrimitive
DistributedPrimitive.Status, DistributedPrimitive.Type 
 - 
 
- 
Field Summary
- 
Fields inherited from interface org.onosproject.store.service.DistributedPrimitive
DEFAULT_OPERATION_TIMEOUT_MILLIS 
 - 
 
- 
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Void>addListener(AtomicValueEventListener<V> listener)Registers the specified listener to be notified whenever the atomic value is updated.default AtomicValue<V>asAtomicValue()Returns a newAtomicValuethat is backed by this instance and with a default operation timeout.default AtomicValue<V>asAtomicValue(long timeoutMillis)Returns a newAtomicValuethat is backed by this instance.java.util.concurrent.CompletableFuture<java.lang.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.java.util.concurrent.CompletableFuture<V>get()Gets the current value.java.util.concurrent.CompletableFuture<V>getAndSet(V value)Atomically sets to the given value and returns the old value.default DistributedPrimitive.TypeprimitiveType()Returns the type of primitive.java.util.concurrent.CompletableFuture<java.lang.Void>removeListener(AtomicValueEventListener<V> listener)Unregisters the specified listener such that it will no longer receive atomic value update notifications.java.util.concurrent.CompletableFuture<java.lang.Void>set(V value)Sets to the given value.- 
Methods inherited from interface org.onosproject.store.service.DistributedPrimitive
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners 
 - 
 
 - 
 
- 
- 
Method Detail
- 
primitiveType
default DistributedPrimitive.Type primitiveType()
Description copied from interface:DistributedPrimitiveReturns the type of primitive.- Specified by:
 primitiveTypein interfaceDistributedPrimitive- Returns:
 - primitive type
 
 
- 
compareAndSet
java.util.concurrent.CompletableFuture<java.lang.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.IMPORTANT: Equality is based on the equality of the serialized {code byte[]} representations.
- Parameters:
 expect- the expected valueupdate- the new value- Returns:
 - CompletableFuture that will be completed with 
trueif update was successful. Otherwise future will be completed with a value offalse 
 
- 
get
java.util.concurrent.CompletableFuture<V> get()
Gets the current value.- Returns:
 - CompletableFuture that will be completed with the value
 
 
- 
getAndSet
java.util.concurrent.CompletableFuture<V> getAndSet(V value)
Atomically sets to the given value and returns the old value.- Parameters:
 value- the new value- Returns:
 - CompletableFuture that will be completed with the previous value
 
 
- 
set
java.util.concurrent.CompletableFuture<java.lang.Void> set(V value)
Sets to the given value.- Parameters:
 value- value to set- Returns:
 - CompletableFuture that will be completed when the operation finishes
 
 
- 
addListener
java.util.concurrent.CompletableFuture<java.lang.Void> addListener(AtomicValueEventListener<V> listener)
Registers the specified listener to be notified whenever the atomic value is updated.- Parameters:
 listener- listener to notify about events- Returns:
 - CompletableFuture that will be completed when the operation finishes
 
 
- 
removeListener
java.util.concurrent.CompletableFuture<java.lang.Void> removeListener(AtomicValueEventListener<V> listener)
Unregisters the specified listener such that it will no longer receive atomic value update notifications.- Parameters:
 listener- listener to unregister- Returns:
 - CompletableFuture that will be completed when the operation finishes
 
 
- 
asAtomicValue
default AtomicValue<V> asAtomicValue(long timeoutMillis)
Returns a newAtomicValuethat is backed by this instance.- Parameters:
 timeoutMillis- timeout duration for the returned ConsistentMap operations- Returns:
 - new 
AtomicValueinstance 
 
- 
asAtomicValue
default AtomicValue<V> asAtomicValue()
Returns a newAtomicValuethat is backed by this instance and with a default operation timeout.- Returns:
 - new 
AtomicValueinstance 
 
 - 
 
 -