Class COUNTER.SyncCounterImpl

  • All Implemented Interfaces:
    Counter, SyncCounter
    Enclosing class:
    COUNTER

    private static class COUNTER.SyncCounterImpl
    extends java.lang.Object
    implements Counter
    • Constructor Detail

      • SyncCounterImpl

        private SyncCounterImpl​(AsyncCounter counter)
    • Method Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface SyncCounter
      • get

        public long get()
        Description copied from interface: SyncCounter
        Gets the current value of the counter
        Specified by:
        get in interface SyncCounter
        Returns:
        The current value
      • set

        public void set​(long new_value)
        Description copied from interface: SyncCounter
        Sets the counter to a new value
        Specified by:
        set in interface SyncCounter
        Parameters:
        new_value - The new value
      • compareAndSwap

        public long compareAndSwap​(long expect,
                                   long update)
        Description copied from interface: SyncCounter
        Atomically updates the counter using a compare-and-swap operation.
        Specified by:
        compareAndSwap in interface Counter
        Specified by:
        compareAndSwap in interface SyncCounter
        Parameters:
        expect - The expected value of the counter
        update - The new value of the counter
        Returns:
        The previous value of the counter
      • addAndGet

        public long addAndGet​(long delta)
        Description copied from interface: SyncCounter
        Atomically adds the given value to the current value.
        Specified by:
        addAndGet in interface SyncCounter
        Parameters:
        delta - the value to add
        Returns:
        the updated value
      • toString

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