Class Counter
- java.lang.Object
-
- io.vertx.mutiny.core.shareddata.Counter
-
public class Counter extends Object
An asynchronous counter that can be used to across the cluster to maintain a consistent count.
NOTE: This class has been automatically generated from theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<Counter>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description Counter(io.vertx.core.shareddata.Counter delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Long>addAndGet(long value)Add the value to the counter atomically and return the new countLongaddAndGetAndAwait(long value)Blocking variant ofaddAndGet(long).io.smallrye.mutiny.Uni<Boolean>compareAndSet(long expected, long value)Set the counter to the specified value only if the current value is the expectec value.BooleancompareAndSetAndAwait(long expected, long value)Blocking variant ofcompareAndSet(long,long).io.smallrye.mutiny.Uni<Long>decrementAndGet()Decrement the counter atomically and return the new countLongdecrementAndGetAndAwait()Blocking variant ofdecrementAndGet().booleanequals(Object o)io.smallrye.mutiny.Uni<Long>get()Get the current value of the counterio.smallrye.mutiny.Uni<Long>getAndAdd(long value)Add the value to the counter atomically and return the value before the addLonggetAndAddAndAwait(long value)Blocking variant ofgetAndAdd(long).LonggetAndAwait()Blocking variant ofget().io.smallrye.mutiny.Uni<Long>getAndIncrement()Increment the counter atomically and return the value before the increment.LonggetAndIncrementAndAwait()Blocking variant ofgetAndIncrement().io.vertx.core.shareddata.CountergetDelegate()inthashCode()io.smallrye.mutiny.Uni<Long>incrementAndGet()Increment the counter atomically and return the new countLongincrementAndGetAndAwait()Blocking variant ofincrementAndGet().static CounternewInstance(io.vertx.core.shareddata.Counter arg)StringtoString()
-
-
-
Method Detail
-
getDelegate
public io.vertx.core.shareddata.Counter getDelegate()
-
get
public io.smallrye.mutiny.Uni<Long> get()
Get the current value of the counterUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
getAndAwait
public Long getAndAwait()
Blocking variant ofget().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Long instance produced by the operation
-
incrementAndGet
public io.smallrye.mutiny.Uni<Long> incrementAndGet()
Increment the counter atomically and return the new countUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
incrementAndGetAndAwait
public Long incrementAndGetAndAwait()
Blocking variant ofincrementAndGet().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Long instance produced by the operation
-
getAndIncrement
public io.smallrye.mutiny.Uni<Long> getAndIncrement()
Increment the counter atomically and return the value before the increment.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
getAndIncrementAndAwait
public Long getAndIncrementAndAwait()
Blocking variant ofgetAndIncrement().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Long instance produced by the operation
-
decrementAndGet
public io.smallrye.mutiny.Uni<Long> decrementAndGet()
Decrement the counter atomically and return the new countUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
decrementAndGetAndAwait
public Long decrementAndGetAndAwait()
Blocking variant ofdecrementAndGet().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Long instance produced by the operation
-
addAndGet
public io.smallrye.mutiny.Uni<Long> addAndGet(long value)
Add the value to the counter atomically and return the new countUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
value- the value to add- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
addAndGetAndAwait
public Long addAndGetAndAwait(long value)
Blocking variant ofaddAndGet(long).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
value- the value to add- Returns:
- the Long instance produced by the operation
-
getAndAdd
public io.smallrye.mutiny.Uni<Long> getAndAdd(long value)
Add the value to the counter atomically and return the value before the addUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
value- the value to add- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
getAndAddAndAwait
public Long getAndAddAndAwait(long value)
Blocking variant ofgetAndAdd(long).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
value- the value to add- Returns:
- the Long instance produced by the operation
-
compareAndSet
public io.smallrye.mutiny.Uni<Boolean> compareAndSet(long expected, long value)
Set the counter to the specified value only if the current value is the expectec value. This happens atomically.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
expected- the expected valuevalue- the new value- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
compareAndSetAndAwait
public Boolean compareAndSetAndAwait(long expected, long value)
Blocking variant ofcompareAndSet(long,long).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
expected- the expected valuevalue- the new value- Returns:
- the Boolean instance produced by the operation
-
newInstance
public static Counter newInstance(io.vertx.core.shareddata.Counter arg)
-
-