Package org.onosproject.store.service
Interface AtomicCounter
-
- All Superinterfaces:
DistributedPrimitive
- All Known Implementing Classes:
DefaultAtomicCounter
public interface AtomicCounter extends DistributedPrimitive
Distributed version of java.util.concurrent.atomic.AtomicLong.
-
-
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 long
addAndGet(long delta)
Atomically adds the given value to the current value.boolean
compareAndSet(long expectedValue, long updateValue)
Atomically sets the given counter to the updated value if the current value is the expected value, otherwise no change occurs.long
get()
Returns the current value of the counter without modifying it.long
getAndAdd(long delta)
Atomically adds the given value to the current value.long
getAndIncrement()
Atomically increment by one the current value.long
incrementAndGet()
Atomically increment by one the current value.default DistributedPrimitive.Type
primitiveType()
Returns the type of primitive.void
set(long value)
Atomically sets the given value to the current 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
-
incrementAndGet
long incrementAndGet()
Atomically increment by one the current value.- Returns:
- updated value
-
getAndIncrement
long getAndIncrement()
Atomically increment by one the current value.- Returns:
- previous value
-
getAndAdd
long getAndAdd(long delta)
Atomically adds the given value to the current value.- Parameters:
delta
- the value to add- Returns:
- previous value
-
addAndGet
long addAndGet(long delta)
Atomically adds the given value to the current value.- Parameters:
delta
- the value to add- Returns:
- updated value
-
set
void set(long value)
Atomically sets the given value to the current value.- Parameters:
value
- the value to set
-
compareAndSet
boolean compareAndSet(long expectedValue, long updateValue)
Atomically sets the given counter to the updated value if the current value is the expected value, otherwise no change occurs.- Parameters:
expectedValue
- the expected current value of the counterupdateValue
- the new value to be set- Returns:
- true if the update occurred and the expected value was equal to the current value, false otherwise
-
get
long get()
Returns the current value of the counter without modifying it.- Returns:
- current value
-
-