# Class: Counter

## vertx-js/counter~ Counter

#### new Counter()

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

  Source:
    - counter.js, line 31

### Methods

#### addAndGet(value, resultHandler)

  Add the value to the counter atomically and return the new count

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | number | the value to add
  `resultHandler` | function | handler which will be passed the value

  Source:
    - counter.js, line 119

#### compareAndSet(expected, value, resultHandler)

  Set the counter to the specified value only if the current value is the expectec value. This happens atomically.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `expected` | number | the expected value
  `value` | number | the new value
  `resultHandler` | function | the handler will be passed true on success

  Source:
    - counter.js, line 161

#### decrementAndGet(resultHandler)

  Decrement the counter atomically and return the new count

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `resultHandler` | function | handler which will be passed the value

  Source:
    - counter.js, line 99

#### get(resultHandler)

  Get the current value of the counter

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `resultHandler` | function | handler which will be passed the value

  Source:
    - counter.js, line 42

#### getAndAdd(value, resultHandler)

  Add the value to the counter atomically and return the value before the add

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | number | the value to add
  `resultHandler` | function | handler which will be passed the value

  Source:
    - counter.js, line 139

#### getAndIncrement(resultHandler)

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `resultHandler` | function | handler which will be passed the value

  Source:
    - counter.js, line 80

#### incrementAndGet(resultHandler)

  Increment the counter atomically and return the new count

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `resultHandler` | function | handler which will be passed the value

  Source:
    - counter.js, line 61