Package: io.vertx.groovy.core.shareddata

## [Groovy] Class Counter

- io.vertx.groovy.core.shareddata.Counter

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

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Counter (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `addAndGet(long value, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)` Add the value to the counter atomically and return the new count
    `void` | `compareAndSet(long expected, long value, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>> resultHandler)` Set the counter to the specified value only if the current value is the expectec value.
    `void` | `decrementAndGet(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)` Decrement the counter atomically and return the new count
    `void` | `get(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)` Get the current value of the counter
    `void` | `getAndAdd(long value, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)` Add the value to the counter atomically and return the value before the add
    `void` | `getAndIncrement(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)` Increment the counter atomically and return the value before the increment.
    `java.lang.Object` | `getDelegate()`
    `void` | `incrementAndGet(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)` Increment the counter atomically and return the new count

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### Counter(java.lang.Object delegate)

  - ### Method Detail

    - #### void addAndGet(long value, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.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

    - #### void compareAndSet(long expected, long value, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.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

    - #### void decrementAndGet(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)

      Decrement the counter atomically and return the new count

      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### void get(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)

      Get the current value of the counter

      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### void getAndAdd(long value, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.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

    - #### void getAndIncrement(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)

      Increment the counter atomically and return the value before the increment.

      Parameters:
        `resultHandler` - handler which will be passed the value

    - #### java.lang.Object getDelegate()

    - #### void incrementAndGet(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)

      Increment the counter atomically and return the new count

      Parameters:
        `resultHandler` - handler which will be passed the value