public class ExecutingAsyncAtomicCounter extends ExecutingDistributedPrimitive implements AsyncAtomicCounter
AsyncAtomicCounter that executes asynchronous callbacks on a user provided
Executor.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
ExecutingAsyncAtomicCounter(AsyncAtomicCounter delegateCounter,
Executor orderedExecutor,
Executor threadPoolExecutor) |
| 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.
|
CompletableFuture<Void> |
set(long value)
Atomically sets the given value to the current value.
|
addStatusChangeListener, asyncFuture, destroy, removeStatusChangeListenerapplicationId, equals, hashCode, name, primitiveType, statusChangeListeners, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasAtomicCounter, asAtomicCounter, primitiveTypeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic ExecutingAsyncAtomicCounter(AsyncAtomicCounter delegateCounter, Executor orderedExecutor, Executor threadPoolExecutor)
public 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