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.

Author:
Tim Fox
See Also:
  • Counter
  • Field Details

  • Constructor Details

    • Counter

      public Counter(io.vertx.core.shareddata.Counter delegate)
      Create a new instance of Counter delegating to the given (non-null) instance of Counter.
    • Counter

      public Counter(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.core.shareddata.Counter getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.get()
    • getAndAwait

      public Long getAndAwait()
      Get the current value of the counter

      Unlike the bare Vert.x variant, this method returns a Long. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.get()
    • getAndForget

      public Counter getAndForget()
      Get the current value of the counter

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.get()
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.incrementAndGet()
    • incrementAndGetAndAwait

      public Long incrementAndGetAndAwait()
      Increment the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method returns a Long. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.incrementAndGet()
    • incrementAndGetAndForget

      public Counter incrementAndGetAndForget()
      Increment the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.incrementAndGet()
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.getAndIncrement()
    • getAndIncrementAndAwait

      public Long getAndIncrementAndAwait()
      Increment the counter atomically and return the value before the increment.

      Unlike the bare Vert.x variant, this method returns a Long. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.getAndIncrement()
    • getAndIncrementAndForget

      public Counter getAndIncrementAndForget()
      Increment the counter atomically and return the value before the increment.

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.getAndIncrement()
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.decrementAndGet()
    • decrementAndGetAndAwait

      public Long decrementAndGetAndAwait()
      Decrement the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method returns a Long. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.decrementAndGet()
    • decrementAndGetAndForget

      public Counter decrementAndGetAndForget()
      Decrement the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.decrementAndGet()
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      value - the value to add
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.addAndGet(long)
    • addAndGetAndAwait

      public Long addAndGetAndAwait(long value)
      Add the value to the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method returns a Long. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.addAndGet(long)
    • addAndGetAndForget

      public Counter addAndGetAndForget(long value)
      Add the value to the counter atomically and return the new count

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Parameters:
      value - the value to add
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.addAndGet(long)
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      value - the value to add
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.getAndAdd(long)
    • getAndAddAndAwait

      public Long getAndAddAndAwait(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 Long. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.getAndAdd(long)
    • getAndAddAndForget

      public Counter getAndAddAndForget(long value)
      Add the value to the counter atomically and return the value before the add

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Parameters:
      value - the value to add
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.getAndAdd(long)
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      expected - the expected value
      value - the new value
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Counter.compareAndSet(long, long)
    • compareAndSetAndAwait

      public Boolean compareAndSetAndAwait(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 Boolean. This method awaits indefinitely 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 operation result
      See Also:
      • Counter.compareAndSet(long, long)
    • compareAndSetAndForget

      public Counter compareAndSetAndForget(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 ignores the Boolean result or any failure.

      Parameters:
      expected - the expected value
      value - the new value
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Counter.compareAndSet(long, long)
    • newInstance

      public static Counter newInstance(io.vertx.core.shareddata.Counter delegate)
      Creates a new instance of the Counter.
    • hashCode

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

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

      public String toString()
      Overrides:
      toString in class Object