All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.core.shareddata.Counter Maven / Gradle / Ivy

There is a newer version: 4.5.10
Show newest version
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * The Apache License v2.0 is available at
 * http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package io.vertx.core.shareddata;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

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

* * * @author Tim Fox */ @VertxGen public interface Counter { /** * Get the current value of the counter * * @param resultHandler handler which will be passed the value */ void get(Handler> resultHandler); /** * Increment the counter atomically and return the new count * * @param resultHandler handler which will be passed the value */ void incrementAndGet(Handler> resultHandler); /** * Increment the counter atomically and return the value before the increment. * * @param resultHandler handler which will be passed the value */ void getAndIncrement(Handler> resultHandler); /** * Decrement the counter atomically and return the new count * * @param resultHandler handler which will be passed the value */ void decrementAndGet(Handler> resultHandler); /** * Add the value to the counter atomically and return the new count * * @param value the value to add * @param resultHandler handler which will be passed the value */ void addAndGet(long value, Handler> resultHandler); /** * Add the value to the counter atomically and return the value before the add * * @param value the value to add * @param resultHandler handler which will be passed the value */ void getAndAdd(long value, Handler> resultHandler); /** * Set the counter to the specified value only if the current value is the expectec value. This happens * atomically. * * @param expected the expected value * @param value the new value * @param resultHandler the handler will be passed true on success */ void compareAndSet(long expected, long value, Handler> resultHandler); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy