Class COUNTER.CounterImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String name  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CounterImpl​(java.lang.String name)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Long> addAndGet​(long delta)
      Atomically adds the given value to the current value.
      java.util.concurrent.CompletableFuture<java.lang.Long> compareAndSwap​(long expect, long update)
      Atomically updates the counter using a compare-and-swap operation.
      java.lang.String getName()  
      java.util.concurrent.CompletableFuture<java.lang.Void> set​(long new_value)
      Sets the counter to a new value.
      SyncCounter sync()
      Returns a SyncCounter wrapper for this instance.
      java.lang.String toString()  
      <T extends Streamable>
      java.util.concurrent.CompletionStage<T>
      update​(CounterFunction<T> updateFunction)
      Atomically updates the counter's value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        protected final java.lang.String name
    • Constructor Detail

      • CounterImpl

        protected CounterImpl​(java.lang.String name)
    • Method Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface BaseCounter
        Returns:
        The counter's name.
      • set

        public java.util.concurrent.CompletableFuture<java.lang.Void> set​(long new_value)
        Description copied from interface: AsyncCounter
        Sets the counter to a new value.
        Specified by:
        set in interface AsyncCounter
        Returns:
        A CompletionStage that is completed with the counter's value is updated.
      • compareAndSwap

        public java.util.concurrent.CompletableFuture<java.lang.Long> compareAndSwap​(long expect,
                                                                                     long update)
        Description copied from interface: AsyncCounter
        Atomically updates the counter using a compare-and-swap operation.
        Specified by:
        compareAndSwap in interface AsyncCounter
        Parameters:
        expect - The expected value of the counter
        update - The new value of the counter
        Returns:
        A CompletionStage that is completed with the current counter's value.
      • addAndGet

        public java.util.concurrent.CompletableFuture<java.lang.Long> addAndGet​(long delta)
        Description copied from interface: AsyncCounter
        Atomically adds the given value to the current value.
        Specified by:
        addAndGet in interface AsyncCounter
        Parameters:
        delta - the value to add
        Returns:
        A CompletionStage that is completed with the updated counter's value.
      • sync

        public SyncCounter sync()
        Description copied from interface: BaseCounter
        Returns a SyncCounter wrapper for this instance. If this counter is already synchronous, then this counter instance is returned (no-op)
        Specified by:
        sync in interface BaseCounter
        Returns:
        The SyncCounter instance;
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object