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.DistributedPrimitiveDistributedPrimitive.Status, DistributedPrimitive.Type
 
- 
 - 
Field Summary- 
Fields inherited from interface org.onosproject.store.service.DistributedPrimitiveDEFAULT_OPERATION_TIMEOUT_MILLIS
 
- 
 - 
Method SummaryAll 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.DistributedPrimitiveaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
 
- 
 
- 
- 
- 
Method Detail- 
primitiveTypedefault DistributedPrimitive.Type primitiveType() Description copied from interface:DistributedPrimitiveReturns the type of primitive.- Specified by:
- primitiveTypein interface- DistributedPrimitive
- Returns:
- primitive type
 
 - 
compareAndSetjava.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 value
- update- the new value
- Returns:
- CompletableFuture that will be completed with trueif update was successful. Otherwise future will be completed with a value offalse
 
 - 
getjava.util.concurrent.CompletableFuture<V> get() Gets the current value.- Returns:
- CompletableFuture that will be completed with the value
 
 - 
getAndSetjava.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
 
 - 
setjava.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
 
 - 
addListenerjava.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
 
 - 
removeListenerjava.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
 
 - 
asAtomicValuedefault 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
 
 - 
asAtomicValuedefault AtomicValue<V> asAtomicValue() Returns a newAtomicValuethat is backed by this instance and with a default operation timeout.- Returns:
- new AtomicValueinstance
 
 
- 
 
-