Interface DistributedAtomicLong

All Known Implementing Classes:
AtomicLongAdapter, RedissonAtomicLongAdapter

public interface DistributedAtomicLong
Common atomic long operations found in both

AtomicLong and RAtomicLong.

  • Method Summary

    Modifier and Type
    Method
    Description
    long
    addAndGet(long delta)
    Atomically adds the given value to the current value.
    boolean
    compareAndSet(long expectedValue, long newValue)
    Atomically sets the value to newValue if the current value == expectedValue.
    long
    Atomically decrements the current value.
    long
    get()
    Returns the current value.
    long
    getAndAdd(long delta)
    Atomically increments the current value.
    long
    Atomically decrements the current value.
    long
    Atomically increments the current value.
    long
    getAndSet(long newValue)
    Atomically sets the value to newValue and returns the old value.
    Returns underlying atomic long.
    long
    Atomically increments the current value by one.
    void
    set(long newValue)
    Sets the value to newValue.
  • Method Details

    • get

      long get()
      Returns the current value.
      Returns:
      the current value
    • set

      void set(long newValue)
      Sets the value to newValue.
      Parameters:
      newValue - the new value
    • getAndSet

      long getAndSet(long newValue)
      Atomically sets the value to newValue and returns the old value.
      Parameters:
      newValue - the new value
      Returns:
      the previous value
    • compareAndSet

      boolean compareAndSet(long expectedValue, long newValue)
      Atomically sets the value to newValue if the current value == expectedValue.
      Parameters:
      expectedValue - the expected value
      newValue - the new value
      Returns:
      true if successful. False return indicates that the actual value was not equal to the expected value.
    • getAndIncrement

      long getAndIncrement()
      Atomically increments the current value.

      Equivalent to addAndGet(1).

      Returns:
      the updated value
    • getAndDecrement

      long getAndDecrement()
      Atomically decrements the current value.
      Returns:
      the previous value
    • getAndAdd

      long getAndAdd(long delta)
      Atomically increments the current value.

      Equivalent to addAndGet(1).

      Returns:
      the updated value
    • incrementAndGet

      long incrementAndGet()
      Atomically increments the current value by one.
      Returns:
      the updated value (value after incrementing)
    • decrementAndGet

      long decrementAndGet()
      Atomically decrements the current value.

      Equivalent to addAndGet(-1).

      Returns:
      the updated value
    • addAndGet

      long addAndGet(long delta)
      Atomically adds the given value to the current value.
      Parameters:
      delta - the value to add
      Returns:
      the updated value
    • getUnderlyingAtomicLong

      Object getUnderlyingAtomicLong()
      Returns underlying atomic long.