Search in sources :

Example 1 with AsynchronousCounter

use of io.vertx.core.shareddata.impl.AsynchronousCounter in project vert.x by eclipse.

the class FakeClusterManager method getCounter.

@Override
public void getCounter(String name, Handler<AsyncResult<Counter>> resultHandler) {
    AtomicLong counter = new AtomicLong();
    AtomicLong prev = counters.putIfAbsent(name, counter);
    if (prev != null) {
        counter = prev;
    }
    AtomicLong theCounter = counter;
    Context context = vertx.getOrCreateContext();
    context.runOnContext(v -> resultHandler.handle(Future.succeededFuture(new AsynchronousCounter(vertx, theCounter))));
}
Also used : Context(io.vertx.core.Context) AtomicLong(java.util.concurrent.atomic.AtomicLong) AsynchronousCounter(io.vertx.core.shareddata.impl.AsynchronousCounter)

Aggregations

Context (io.vertx.core.Context)1 AsynchronousCounter (io.vertx.core.shareddata.impl.AsynchronousCounter)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1