Class Counter

java.lang.Object
io.vertx.mutiny.core.shareddata.Counter
All Implemented Interfaces:
MutinyDelegate

public class Counter extends Object implements MutinyDelegate
An asynchronous counter that can be used to across the cluster to maintain a consistent count.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • Counter

      public Counter(io.vertx.core.shareddata.Counter delegate)
    • Counter

      public Counter(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.core.shareddata.Counter getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • get

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> get()
      Get the current value of the counter

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getAndAwait

      public Long getAndAwait()
      Blocking variant of get().

      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.
    • getAndForget

      public void getAndForget()
      Variant of get() that ignores the result of the operation.

      This method subscribes on the result of get(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from get() but you don't need to compose it with other operations.

    • incrementAndGet

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> incrementAndGet()
      Increment the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • incrementAndGetAndAwait

      public Long incrementAndGetAndAwait()
      Blocking variant of incrementAndGet().

      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.
    • incrementAndGetAndForget

      public void incrementAndGetAndForget()
      Variant of incrementAndGet() that ignores the result of the operation.

      This method subscribes on the result of incrementAndGet(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from incrementAndGet() but you don't need to compose it with other operations.

    • getAndIncrement

      @CheckReturnValue 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 uni firing the result of the operation when completed, or a failure if the operation failed.
    • getAndIncrementAndAwait

      public Long getAndIncrementAndAwait()
      Blocking variant of getAndIncrement().

      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.
    • getAndIncrementAndForget

      public void getAndIncrementAndForget()
      Variant of getAndIncrement() that ignores the result of the operation.

      This method subscribes on the result of getAndIncrement(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getAndIncrement() but you don't need to compose it with other operations.

    • decrementAndGet

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> decrementAndGet()
      Decrement the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • decrementAndGetAndAwait

      public Long decrementAndGetAndAwait()
      Blocking variant of decrementAndGet().

      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.
    • decrementAndGetAndForget

      public void decrementAndGetAndForget()
      Variant of decrementAndGet() that ignores the result of the operation.

      This method subscribes on the result of decrementAndGet(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from decrementAndGet() but you don't need to compose it with other operations.

    • addAndGet

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> addAndGet(long value)
      Add the value to the counter atomically and return the new count

      Unlike 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 uni firing the result of the operation when completed, or a failure if the operation failed.
    • addAndGetAndAwait

      public Long addAndGetAndAwait(long value)
      Blocking variant of addAndGet(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.
    • addAndGetAndForget

      public void addAndGetAndForget(long value)
      Variant of addAndGet(long) that ignores the result of the operation.

      This method subscribes on the result of addAndGet(long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from addAndGet(long) but you don't need to compose it with other operations.

      Parameters:
      value - the value to add
    • getAndAdd

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> getAndAdd(long value)
      Add the value to the counter atomically and return the value before the add

      Unlike 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 uni firing the result of the operation when completed, or a failure if the operation failed.
    • getAndAddAndAwait

      public Long getAndAddAndAwait(long value)
      Blocking variant of getAndAdd(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.
    • getAndAddAndForget

      public void getAndAddAndForget(long value)
      Variant of getAndAdd(long) that ignores the result of the operation.

      This method subscribes on the result of getAndAdd(long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getAndAdd(long) but you don't need to compose it with other operations.

      Parameters:
      value - the value to add
    • compareAndSet

      @CheckReturnValue 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 value
      value - the new value
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • compareAndSetAndAwait

      public Boolean compareAndSetAndAwait(long expected, long value)
      Blocking variant of compareAndSet(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 value
      value - the new value
      Returns:
      the Boolean instance produced by the operation.
    • compareAndSetAndForget

      public void compareAndSetAndForget(long expected, long value)
      Variant of compareAndSet(long,long) that ignores the result of the operation.

      This method subscribes on the result of compareAndSet(long,long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from compareAndSet(long,long) but you don't need to compose it with other operations.

      Parameters:
      expected - the expected value
      value - the new value
    • newInstance

      public static Counter newInstance(io.vertx.core.shareddata.Counter arg)