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

org.infinispan.counter.api.WeakCounter Maven / Gradle / Ivy

package org.infinispan.counter.api;

import java.util.concurrent.CompletableFuture;

/**
 * A weak consistent counter interface.
 * 

* This interface represents a weak counter in the way that the write operations does not return a consistent results. * In this way, all the writes return a {@link CompletableFuture}. *

* Note: the reset operation is not atomic. * * @author Pedro Ruivo * @since 9.0 */ public interface WeakCounter { /** * @return The counter name. */ String getName(); /** * It returns the counter's value. *

* This value may be not the mot up-to-data value. * * @return The counter's value. */ long getValue(); /** * Increments the counter. */ default CompletableFuture increment() { return add(1L); } /** * Decrements the counter. */ default CompletableFuture decrement() { return add(-1L); } /** * Adds the given value to the new value. * * @param delta the value to add. */ CompletableFuture add(long delta); /** * Resets the counter to its initial value. */ CompletableFuture reset(); /** * Adds a {@link CounterListener} to this counter. * * @param listener The listener to add. * @param The type of the listener. It must implement {@link CounterListener}. * @return A {@link Handle} that allows to remove the listener via {@link Handle#remove()} ()}. */ Handle addListener(T listener); /** * @return the {@link CounterConfiguration} used by this counter. */ CounterConfiguration getConfiguration(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy