Class AtomicLongArray

java.lang.Object
dev.gmitch215.bytebox.locks.AtomicLongArray

public class AtomicLongArray extends Object
java.util.concurrent.atomic.AtomicLongArray, which the class library does not carry even though it carries AtomicLong.

Indivisible for the same reason as AtomicReferenceArray: one fiber runs at a time and none of these operations suspends, so no two of them interleave.

Since:
1.0.2
  • Constructor Details

    • AtomicLongArray

      public AtomicLongArray(int length)
      Parameters:
      length - how many elements, each starting zero
    • AtomicLongArray

      public AtomicLongArray(long[] array)
      Parameters:
      array - the elements to copy
  • Method Details

    • length

      public final int length()
      Returns how many elements.
      Returns:
      how many elements
    • get

      public final long get(int i)
      Parameters:
      i - the index
      Returns:
      the element
    • set

      public final void set(int i, long newValue)
      Parameters:
      i - the index
      newValue - the value to store
    • lazySet

      public final void lazySet(int i, long newValue)
      Parameters:
      i - the index
      newValue - the value to store
    • getAndSet

      public final long getAndSet(int i, long newValue)
      Parameters:
      i - the index
      newValue - the value to store
      Returns:
      the value that was there
    • compareAndSet

      public final boolean compareAndSet(int i, long expect, long update)
      Parameters:
      i - the index
      expect - the value that must be there
      update - the value to store
      Returns:
      whether it was stored
    • weakCompareAndSet

      public final boolean weakCompareAndSet(int i, long expect, long update)
      Parameters:
      i - the index
      expect - the value that must be there
      update - the value to store
      Returns:
      whether it was stored
    • getAndAdd

      public final long getAndAdd(int i, long delta)
      Parameters:
      i - the index
      delta - how much to add
      Returns:
      the value before adding
    • addAndGet

      public final long addAndGet(int i, long delta)
      Parameters:
      i - the index
      delta - how much to add
      Returns:
      the value after adding
    • getAndIncrement

      public final long getAndIncrement(int i)
      Parameters:
      i - the index
      Returns:
      the value before incrementing
    • getAndDecrement

      public final long getAndDecrement(int i)
      Parameters:
      i - the index
      Returns:
      the value before decrementing
    • incrementAndGet

      public final long incrementAndGet(int i)
      Parameters:
      i - the index
      Returns:
      the value after incrementing
    • decrementAndGet

      public final long decrementAndGet(int i)
      Parameters:
      i - the index
      Returns:
      the value after decrementing
    • toString

      public String toString()
      Overrides:
      toString in class Object