Interface MutinyStrongCounter
public interface MutinyStrongCounter
The strong consistent counter interface.
It provides atomic updates for the counter. All the operations are perform asynchronously and they complete the
Uni when completed.
- Since:
- 14.0
-
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Long> addAndGet(long delta) Atomically adds the given value and return the new value.io.smallrye.mutiny.Uni<Boolean> compareAndSet(long expect, long update) Atomically sets the value to the given updated value if the current value==the expected value.io.smallrye.mutiny.Uni<Long> compareAndSwap(long expect, long update) Atomically sets the value to the given updated value if the current value==the expected value.Return the container of this counterdefault io.smallrye.mutiny.Uni<Long> Atomically decrements the counter and returns the new valueio.smallrye.mutiny.Uni<Long> getAndSet(long value) Atomically sets the value to the given updated valueio.smallrye.mutiny.Uni<CounterConfiguration> default io.smallrye.mutiny.Uni<Long> Atomically increments the counter and returns the new value.io.smallrye.mutiny.Multi<CounterEvent> listen()Listens to counter events.name()io.smallrye.mutiny.Uni<Void> reset()Resets the counter to its initial value.io.smallrye.mutiny.Uni<Long> value()It fetches the current value.
-
Method Details
-
name
String name()- Returns:
- The counter name.
-
container
-
value
io.smallrye.mutiny.Uni<Long> value()It fetches the current value.It may go remotely to fetch the current value.
- Returns:
- The current value.
-
incrementAndGet
Atomically increments the counter and returns the new value.- Returns:
- The new value.
-
decrementAndGet
Atomically decrements the counter and returns the new value- Returns:
- The new value.
-
addAndGet
Atomically adds the given value and return the new value.- Parameters:
delta- The non-zero value to add. It can be negative.- Returns:
- The new value.
-
reset
io.smallrye.mutiny.Uni<Void> reset()Resets the counter to its initial value. -
listen
io.smallrye.mutiny.Multi<CounterEvent> listen()Listens to counter events.- Returns:
- a
Multiwhich producesCacheEntryEventitems.
-
compareAndSet
Atomically sets the value to the given updated value if the current value==the expected value.It is the same as
return compareAndSwap(expect, update).thenApply(value -> value == expect);- Parameters:
expect- the expected valueupdate- the new value- Returns:
trueif successful,falseotherwise.
-
compareAndSwap
Atomically sets the value to the given updated value if the current value==the expected value.The operation is successful if the return value is equals to the expected value.
- Parameters:
expect- the expected value.update- the new value.- Returns:
- the previous counter's value.
-
getAndSet
Atomically sets the value to the given updated value- Parameters:
value- the new value.- Returns:
- the old counter's value.
-
getConfiguration
io.smallrye.mutiny.Uni<CounterConfiguration> getConfiguration()
-