io.vertx.core.shareddata

## Interface Counter

-     public interface Counter

  An asynchronous counter that can be used to across the cluster to maintain a consistent count.

  Author:
    Tim Fox

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Future<Long>` | `addAndGet(long value)` Same as `addAndGet(long, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `addAndGet(long value, Handler<AsyncResult<Long>> resultHandler)` Add the value to the counter atomically and return the new count
    `Future<Boolean>` | `compareAndSet(long expected, long value)` Same as `compareAndSet(long, long, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `compareAndSet(long expected, long value, Handler<AsyncResult<Boolean>> resultHandler)` Set the counter to the specified value only if the current value is the expectec value.
    `Future<Long>` | `decrementAndGet()` Same as `decrementAndGet(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `decrementAndGet(Handler<AsyncResult<Long>> resultHandler)` Decrement the counter atomically and return the new count
    `Future<Long>` | `get()` Same as `get(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `get(Handler<AsyncResult<Long>> resultHandler)` Get the current value of the counter
    `Future<Long>` | `getAndAdd(long value)` Same as `getAndAdd(long, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `getAndAdd(long value, Handler<AsyncResult<Long>> resultHandler)` Add the value to the counter atomically and return the value before the add
    `Future<Long>` | `getAndIncrement()` Same as `getAndIncrement(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `getAndIncrement(Handler<AsyncResult<Long>> resultHandler)` Increment the counter atomically and return the value before the increment.
    `Future<Long>` | `incrementAndGet()` Same as `incrementAndGet(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `incrementAndGet(Handler<AsyncResult<Long>> resultHandler)` Increment the counter atomically and return the new count

- - ### Method Detail

    - #### get

          default void get(Handler<AsyncResult<Long>> resultHandler)

      Get the current value of the counter
      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### get

          Future<Long> get()

      Same as `get(Handler)` but returns a `Future` of the asynchronous result

    - #### incrementAndGet

          default void incrementAndGet(Handler<AsyncResult<Long>> resultHandler)

      Increment the counter atomically and return the new count
      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### incrementAndGet

          Future<Long> incrementAndGet()

      Same as `incrementAndGet(Handler)` but returns a `Future` of the asynchronous result

    - #### getAndIncrement

          default void getAndIncrement(Handler<AsyncResult<Long>> resultHandler)

      Increment the counter atomically and return the value before the increment.
      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### getAndIncrement

          Future<Long> getAndIncrement()

      Same as `getAndIncrement(Handler)` but returns a `Future` of the asynchronous result

    - #### decrementAndGet

          default void decrementAndGet(Handler<AsyncResult<Long>> resultHandler)

      Decrement the counter atomically and return the new count
      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### decrementAndGet

          Future<Long> decrementAndGet()

      Same as `decrementAndGet(Handler)` but returns a `Future` of the asynchronous result

    - #### addAndGet

          default void addAndGet(long value,
                                 Handler<AsyncResult<Long>> resultHandler)

      Add the value to the counter atomically and return the new count
      Parameters:
        `value` - the value to add
        `resultHandler` - handler which will be passed the value

    - #### addAndGet

          Future<Long> addAndGet(long value)

      Same as `addAndGet(long, Handler)` but returns a `Future` of the asynchronous result

    - #### getAndAdd

          default void getAndAdd(long value,
                                 Handler<AsyncResult<Long>> resultHandler)

      Add the value to the counter atomically and return the value before the add
      Parameters:
        `value` - the value to add
        `resultHandler` - handler which will be passed the value

    - #### getAndAdd

          Future<Long> getAndAdd(long value)

      Same as `getAndAdd(long, Handler)` but returns a `Future` of the asynchronous result

    - #### compareAndSet

          default void compareAndSet(long expected,
                                     long value,
                                     Handler<AsyncResult<Boolean>> resultHandler)

      Set the counter to the specified value only if the current value is the expectec value. This happens atomically.
      Parameters:
        `expected` - the expected value
        `value` - the new value
        `resultHandler` - the handler will be passed true on success

    - #### compareAndSet

          Future<Boolean> compareAndSet(long expected,
                                        long value)

      Same as `compareAndSet(long, long, Handler)` but returns a `Future` of the asynchronous result

Copyright © 2021 Eclipse. All rights reserved.