Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Counter

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

Hierarchy

  • Counter

Index

Methods

addAndGet

  • addAndGet(value: number): PromiseLike<number>
  • addAndGet(value: number, resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): void
  • Add the value to the counter atomically and return the new count

    Parameters

    • value: number

    Returns PromiseLike<number>

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

    Parameters

    Returns void

compareAndSet

  • compareAndSet(expected: number, value: number): PromiseLike<boolean>
  • compareAndSet(expected: number, value: number, resultHandler: ((res: AsyncResult<boolean>) => void) | Handler<AsyncResult<boolean>>): void
  • Set the counter to the specified value only if the current value is the expectec value. This happens atomically.

    Parameters

    • expected: number
    • value: number

    Returns PromiseLike<boolean>

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

    Parameters

    Returns void

decrementAndGet

  • decrementAndGet(): PromiseLike<number>
  • decrementAndGet(resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): void
  • Decrement the counter atomically and return the new count

    Returns PromiseLike<number>

  • Decrement the counter atomically and return the new count

    Parameters

    Returns void

get

  • Get the current value of the counter

    Returns PromiseLike<number>

  • Get the current value of the counter

    Parameters

    Returns void

getAndAdd

  • getAndAdd(value: number): PromiseLike<number>
  • getAndAdd(value: number, resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): void
  • Add the value to the counter atomically and return the value before the add

    Parameters

    • value: number

    Returns PromiseLike<number>

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

    Parameters

    Returns void

getAndIncrement

  • getAndIncrement(): PromiseLike<number>
  • getAndIncrement(resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): void
  • Increment the counter atomically and return the value before the increment.

    Returns PromiseLike<number>

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

    Parameters

    Returns void

incrementAndGet

  • incrementAndGet(): PromiseLike<number>
  • incrementAndGet(resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): void
  • Increment the counter atomically and return the new count

    Returns PromiseLike<number>

  • Increment the counter atomically and return the new count

    Parameters

    Returns void

Generated using TypeDoc