public interface StrongCounter
It provides atomic updates for the counter. All the operations are perform asynchronously and they complete the
CompletableFuture
when completed.
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Long> |
addAndGet(long delta)
Atomically adds the given value and return the new value.
|
<T extends CounterListener> |
addListener(T listener)
Registers a
CounterListener to this counter. |
default CompletableFuture<Boolean> |
compareAndSet(long expect,
long update)
Atomically sets the value to the given updated value if the current value
== the expected value. |
CompletableFuture<Long> |
compareAndSwap(long expect,
long update)
Atomically sets the value to the given updated value if the current value
== the expected value. |
default CompletableFuture<Long> |
decrementAndGet()
Atomically decrements the counter and returns the new value
|
CounterConfiguration |
getConfiguration() |
String |
getName() |
CompletableFuture<Long> |
getValue()
It fetches the current value.
|
default CompletableFuture<Long> |
incrementAndGet()
Atomically increments the counter and returns the new value.
|
CompletableFuture<Void> |
remove()
It removes this counter from the cluster.
|
CompletableFuture<Void> |
reset()
Resets the counter to its initial value.
|
SyncStrongCounter |
sync()
It returns a synchronous strong counter for this instance.
|
String getName()
CompletableFuture<Long> getValue()
It may go remotely to fetch the current value.
default CompletableFuture<Long> incrementAndGet()
default CompletableFuture<Long> decrementAndGet()
CompletableFuture<Long> addAndGet(long delta)
delta
- The non-zero value to add. It can be negative.CompletableFuture<Void> reset()
<T extends CounterListener> Handle<T> addListener(T listener)
CounterListener
to this counter.T
- The concrete type of the listener. It must implement CounterListener
.listener
- The listener to register.Handle
that allows to remove the listener via Handle.remove()
.default CompletableFuture<Boolean> compareAndSet(long expect, long update)
==
the expected value.
It is the same as return compareAndSwap(expect, update).thenApply(value -> value == expect);
expect
- the expected valueupdate
- the new valuetrue
if successful, false
otherwise.CompletableFuture<Long> compareAndSwap(long expect, long update)
==
the expected value.
The operation is successful if the return value is equals to the expected value.expect
- the expected value.update
- the new value.CounterConfiguration getConfiguration()
CounterConfiguration
used by this counter.CompletableFuture<Void> remove()
Note that it doesn't remove the counter from the CounterManager
. If you want to remove the counter from
the CounterManager
use CounterManager.remove(String)
.
CompletableFuture
that is completed when the counter is removed from the cluster.SyncStrongCounter sync()
SyncStrongCounter
.Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.