Top Description Methods
io.vertx.core.shareddata

public Interface Counter

Known Direct Implementers
io.vertx.core.shareddata.impl.AsynchronousCounter
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.VertxGen, io.vertx.core.AsyncResult, .Future, .Handler, java.util.Objects

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

Author
Tim Fox

Method Summary

Modifier and TypeMethod and Description
public default void
addAndGet(long
the value to add
value
,
Handler<AsyncResult<Long>>
handler which will be passed the value
resultHandler
)

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

public Future<Long>
addAndGet(long value)

Same as addAndGet(long, Handler) but returns a Future of the asynchronous result

public default void
compareAndSet(long
the expected value
expected
,
long
the new value
value
,
Handler<AsyncResult<Boolean>>
the handler will be passed true on success
resultHandler
)

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

public Future<Boolean>
compareAndSet(long expected, long value)

Same as compareAndSet(long, long, Handler) but returns a Future of the asynchronous result

public default void
decrementAndGet(Handler<AsyncResult<Long>>
handler which will be passed the value
resultHandler
)

Decrement the counter atomically and return the new count

public Future<Long>
decrementAndGet()

Same as decrementAndGet(Handler) but returns a Future of the asynchronous result

public default void
get(Handler<AsyncResult<Long>>
handler which will be passed the value
resultHandler
)

Get the current value of the counter

public Future<Long>
get()

Same as get(Handler) but returns a Future of the asynchronous result

public default void
getAndAdd(long
the value to add
value
,
Handler<AsyncResult<Long>>
handler which will be passed the value
resultHandler
)

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

public Future<Long>
getAndAdd(long value)

Same as getAndAdd(long, Handler) but returns a Future of the asynchronous result

public default void
getAndIncrement(Handler<AsyncResult<Long>>
handler which will be passed the value
resultHandler
)

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

public Future<Long>
getAndIncrement()

Same as getAndIncrement(Handler) but returns a Future of the asynchronous result

public default void
incrementAndGet(Handler<AsyncResult<Long>>
handler which will be passed the value
resultHandler
)

Increment the counter atomically and return the new count

public Future<Long>
incrementAndGet()

Same as incrementAndGet(Handler) but returns a Future of the asynchronous result

Method Detail

addAndGetback to summary
public default void addAndGet(long value, Handler<AsyncResult<Long>> resultHandler)

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

Parameters
value:long

the value to add

resultHandler:Handler<AsyncResult<Long>>

handler which will be passed the value

addAndGetback to summary
public Future<Long> addAndGet(long value)

Same as addAndGet(long, Handler) but returns a Future of the asynchronous result

compareAndSetback to summary
public default 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:long

the expected value

value:long

the new value

resultHandler:Handler<AsyncResult<Boolean>>

the handler will be passed true on success

compareAndSetback to summary
public Future<Boolean> compareAndSet(long expected, long value)

Same as compareAndSet(long, long, Handler) but returns a Future of the asynchronous result

decrementAndGetback to summary
public default void decrementAndGet(Handler<AsyncResult<Long>> resultHandler)

Decrement the counter atomically and return the new count

Parameters
resultHandler:Handler<AsyncResult<Long>>

handler which will be passed the value

decrementAndGetback to summary
public Future<Long> decrementAndGet()

Same as decrementAndGet(Handler) but returns a Future of the asynchronous result

getback to summary
public default void get(Handler<AsyncResult<Long>> resultHandler)

Get the current value of the counter

Parameters
resultHandler:Handler<AsyncResult<Long>>

handler which will be passed the value

getback to summary
public Future<Long> get()

Same as get(Handler) but returns a Future of the asynchronous result

getAndAddback to summary
public default void getAndAdd(long value, Handler<AsyncResult<Long>> resultHandler)

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

Parameters
value:long

the value to add

resultHandler:Handler<AsyncResult<Long>>

handler which will be passed the value

getAndAddback to summary
public Future<Long> getAndAdd(long value)

Same as getAndAdd(long, Handler) but returns a Future of the asynchronous result

getAndIncrementback to summary
public default void getAndIncrement(Handler<AsyncResult<Long>> resultHandler)

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

Parameters
resultHandler:Handler<AsyncResult<Long>>

handler which will be passed the value

getAndIncrementback to summary
public Future<Long> getAndIncrement()

Same as getAndIncrement(Handler) but returns a Future of the asynchronous result

incrementAndGetback to summary
public default void incrementAndGet(Handler<AsyncResult<Long>> resultHandler)

Increment the counter atomically and return the new count

Parameters
resultHandler:Handler<AsyncResult<Long>>

handler which will be passed the value

incrementAndGetback to summary
public Future<Long> incrementAndGet()

Same as incrementAndGet(Handler) but returns a Future of the asynchronous result