public class AtomixCounter extends Object implements AsyncAtomicCounter
AsyncAtomicCounter implementation backed by Atomix
DistributedLong.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
AtomixCounter(String name,
io.atomix.variables.DistributedLong distLong) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Long> |
addAndGet(long delta)
Atomically adds the given value to the current value.
|
CompletableFuture<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.
|
CompletableFuture<Long> |
get()
Returns the current value of the counter without modifying it.
|
CompletableFuture<Long> |
getAndAdd(long delta)
Atomically adds the given value to the current value.
|
CompletableFuture<Long> |
getAndIncrement()
Atomically increment by one the current value.
|
CompletableFuture<Long> |
incrementAndGet()
Atomically increment by one the current value.
|
String |
name()
Returns the name of this primitive.
|
CompletableFuture<Void> |
set(long value)
Atomically sets the given value to the current value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasAtomicCounter, asAtomicCounter, primitiveTypeaddStatusChangeListener, applicationId, destroy, removeStatusChangeListener, statusChangeListenerspublic AtomixCounter(String name, io.atomix.variables.DistributedLong distLong)
public String name()
DistributedPrimitivename in interface DistributedPrimitivepublic CompletableFuture<Long> incrementAndGet()
AsyncAtomicCounterincrementAndGet in interface AsyncAtomicCounterpublic CompletableFuture<Long> getAndIncrement()
AsyncAtomicCountergetAndIncrement in interface AsyncAtomicCounterpublic CompletableFuture<Long> getAndAdd(long delta)
AsyncAtomicCountergetAndAdd in interface AsyncAtomicCounterdelta - the value to addpublic CompletableFuture<Long> addAndGet(long delta)
AsyncAtomicCounteraddAndGet in interface AsyncAtomicCounterdelta - the value to addpublic CompletableFuture<Long> get()
AsyncAtomicCounterget in interface AsyncAtomicCounterpublic CompletableFuture<Void> set(long value)
AsyncAtomicCounterset in interface AsyncAtomicCountervalue - new valuepublic CompletableFuture<Boolean> compareAndSet(long expectedValue, long updateValue)
AsyncAtomicCountercompareAndSet in interface AsyncAtomicCounterexpectedValue - the expected current value of the counterupdateValue - the new value to be set