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
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAndGet(long value, Handler<AsyncResult<Long>> resultHandler)` Add the value to the counter atomically and return the new count
    `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.
    `void` | `decrementAndGet(Handler<AsyncResult<Long>> resultHandler)` Decrement the counter atomically and return the new count
    `void` | `get(Handler<AsyncResult<Long>> resultHandler)` Get the current value of the counter
    `void` | `getAndAdd(long value, Handler<AsyncResult<Long>> resultHandler)` Add the value to the counter atomically and return the value before the add
    `void` | `getAndIncrement(Handler<AsyncResult<Long>> resultHandler)` Increment the counter atomically and return the value before the increment.
    `void` | `incrementAndGet(Handler<AsyncResult<Long>> resultHandler)` Increment the counter atomically and return the new count

- - ### Method Detail

    - #### get

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

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

    - #### incrementAndGet

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

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

    - #### getAndIncrement

          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

    - #### decrementAndGet

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

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

    - #### addAndGet

          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

    - #### getAndAdd

          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

    - #### compareAndSet

          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

Copyright © 2019 Eclipse. All rights reserved.