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

org.infinispan.counter.impl.strong.UnboundedStrongCounter Maven / Gradle / Ivy

The newest version!
package org.infinispan.counter.impl.strong;

import org.infinispan.AdvancedCache;
import org.infinispan.counter.api.CounterConfiguration;
import org.infinispan.counter.impl.entries.CounterValue;
import org.infinispan.counter.impl.listener.CounterManagerNotificationManager;

/**
 * An unbounded strong consistent counter.
 *
 * @author Pedro Ruivo
 * @see AbstractStrongCounter
 * @since 9.0
 */
public class UnboundedStrongCounter extends AbstractStrongCounter {

   public UnboundedStrongCounter(String counterName, AdvancedCache cache,
                                 CounterConfiguration configuration, CounterManagerNotificationManager notificationManager) {
      super(counterName, cache, configuration, notificationManager);
   }

   @Override
   protected Long handleCASResult(Object state) {
      assert state instanceof Long;
      return (Long) state;
   }

   @Override
   protected long handleAddResult(CounterValue counterValue) {
      return counterValue.getValue();
   }

   @Override
   protected Long handleSetResult(Object state) {
      assert state instanceof Long;
      return (Long) state;
   }

   @Override
   public String toString() {
      return "UnboundedStrongCounter{" +
            "counterName=" + key.getCounterName() +
            '}';
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy