new Counter()
An asynchronous counter that can be used to across the cluster to maintain a consistent count.
- Source:
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:
-
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:
-
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:
-
get(resultHandler)
-
Get the current value of the counter
Parameters:
Name Type Description resultHandler
function handler which will be passed the value - Source:
-
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:
-
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:
-
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: