Package org.onosproject.store.service
Interface AsyncAtomicValue<V>
-
- Type Parameters:
V
- value type
- All Superinterfaces:
DistributedPrimitive
public interface AsyncAtomicValue<V> extends DistributedPrimitive
-
-
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 CompletableFuture<Void>
addListener(AtomicValueEventListener<V> listener)
Registers the specified listener to be notified whenever the atomic value is updated.default AtomicValue<V>
asAtomicValue()
Returns a newAtomicValue
that is backed by this instance and with a default operation timeout.default AtomicValue<V>
asAtomicValue(long timeoutMillis)
Returns a newAtomicValue
that is backed by this instance.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.default DistributedPrimitive.Type
primitiveType()
Returns the type of 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.-
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:DistributedPrimitive
Returns the type of primitive.- Specified by:
primitiveType
in interfaceDistributedPrimitive
- Returns:
- primitive type
-
compareAndSet
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.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
true
if update was successful. Otherwise future will be completed with a value offalse
-
get
CompletableFuture<V> get()
Gets the current value.- Returns:
- CompletableFuture that will be completed with the value
-
getAndSet
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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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 newAtomicValue
that is backed by this instance.- Parameters:
timeoutMillis
- timeout duration for the returned ConsistentMap operations- Returns:
- new
AtomicValue
instance
-
asAtomicValue
default AtomicValue<V> asAtomicValue()
Returns a newAtomicValue
that is backed by this instance and with a default operation timeout.- Returns:
- new
AtomicValue
instance
-
-