Class PaddedAtomicLong

    • Constructor Detail

      • PaddedAtomicLong

        public PaddedAtomicLong()
        Creates a new PaddedAtomicLong with initial value 0.
      • PaddedAtomicLong

        public PaddedAtomicLong​(long initialValue)
        Creates a new PaddedAtomicLong with the given initial value.
        Parameters:
        initialValue - the initial value
    • Method Detail

      • get

        public long get()
        Gets the current value.
        Returns:
        the current value
        See Also:
        AtomicLong.get()
      • set

        public void set​(long newValue)
        Sets to the given value.
        Parameters:
        newValue - the new value
        See Also:
        AtomicLong.set(long)
      • lazySet

        public void lazySet​(long newValue)
        Eventually sets to the given value.
        Parameters:
        newValue - the new value
        See Also:
        AtomicLong.lazySet(long)
      • getAndSet

        public long getAndSet​(long newValue)
        Atomically sets to the given value and returns the old value.
        Parameters:
        newValue - the new value
        Returns:
        the previous value
        See Also:
        AtomicLong.getAndSet(long)
      • compareAndSet

        public boolean compareAndSet​(long expect,
                                     long update)
        Atomically sets the value to the given updated value if the current value == the expected value.
        Parameters:
        expect - the expected value
        update - the new value
        Returns:
        true if successful. False return indicates that the actual value was not equal to the expected value.
        See Also:
        AtomicLong.compareAndSet(long, long)
      • getAndIncrement

        public long getAndIncrement()
        Atomically increments the current value by 1.
        Returns:
        the previous value
        See Also:
        AtomicLong.getAndIncrement()
      • getAndDecrement

        public long getAndDecrement()
        Atomically decrements the current value by 1.
        Returns:
        the previous value
        See Also:
        AtomicLong.getAndDecrement()
      • getAndAdd

        public long getAndAdd​(long delta)
        Atomically adds to the current value the given value.
        Parameters:
        delta - the value to add
        Returns:
        the previous value
        See Also:
        AtomicLong.getAndAdd(long)
      • incrementAndGet

        public long incrementAndGet()
        Atomically increments the current value by one.
        Returns:
        the updated value
        See Also:
        AtomicLong.incrementAndGet()
      • decrementAndGet

        public long decrementAndGet()
        Atomically decrements the current value by one.
        Returns:
        the updated value
        See Also:
        AtomicLong.decrementAndGet()
      • addAndGet

        public long addAndGet​(long delta)
        Atomically adds to current value te given value.
        Parameters:
        delta - the value to add
        Returns:
        the updated value
        See Also:
        AtomicLong.addAndGet(long)
      • getAndUpdate

        public long getAndUpdate​(LongUnaryOperator updateFunction)
        Atomically updates the current value with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
        Parameters:
        updateFunction - a side-effect-free function
        Returns:
        the previous value
        See Also:
        AtomicLong.getAndUpdate(LongUnaryOperator)
      • updateAndGet

        public long updateAndGet​(LongUnaryOperator updateFunction)
        Atomically updates the current value with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
        Parameters:
        updateFunction - a side-effect-free function
        Returns:
        the updated value
        See Also:
        AtomicLong.updateAndGet(LongUnaryOperator)
      • getAndAccumulate

        public long getAndAccumulate​(long v,
                                     LongBinaryOperator f)
        Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument.
        Parameters:
        v - the update value
        f - a side-effect-free function of two arguments
        Returns:
        the previous value
        See Also:
        AtomicLong.getAndAccumulate(long, LongBinaryOperator)
      • toString

        public String toString()
        Returns the String representation of the current value.
        Overrides:
        toString in class Object
        Returns:
        the String representation of the current value
      • spVal

        public void spVal​(long v)
      • soVal

        public void soVal​(long v)
      • svVal

        public void svVal​(long v)
      • lvVal

        public long lvVal()
      • lpVal

        public long lpVal()
      • casVal

        public boolean casVal​(long expectedV,
                              long newV)
      • getAndSetVal

        public long getAndSetVal​(long v)
      • getAndAddVal

        public long getAndAddVal​(long delta)