Package dev.gmitch215.bytebox.locks
Class AtomicLongArray
java.lang.Object
dev.gmitch215.bytebox.locks.AtomicLongArray
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal longaddAndGet(int i, long delta) final booleancompareAndSet(int i, long expect, long update) final longdecrementAndGet(int i) final longget(int i) final longgetAndAdd(int i, long delta) final longgetAndDecrement(int i) final longgetAndIncrement(int i) final longgetAndSet(int i, long newValue) final longincrementAndGet(int i) final voidlazySet(int i, long newValue) final intlength()Returns how many elements.final voidset(int i, long newValue) toString()final booleanweakCompareAndSet(int i, long expect, long update)
-
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 indexnewValue- the value to store
-
lazySet
public final void lazySet(int i, long newValue) - Parameters:
i- the indexnewValue- the value to store
-
getAndSet
public final long getAndSet(int i, long newValue) - Parameters:
i- the indexnewValue- the value to store- Returns:
- the value that was there
-
compareAndSet
public final boolean compareAndSet(int i, long expect, long update) - Parameters:
i- the indexexpect- the value that must be thereupdate- the value to store- Returns:
- whether it was stored
-
weakCompareAndSet
public final boolean weakCompareAndSet(int i, long expect, long update) - Parameters:
i- the indexexpect- the value that must be thereupdate- the value to store- Returns:
- whether it was stored
-
getAndAdd
public final long getAndAdd(int i, long delta) - Parameters:
i- the indexdelta- how much to add- Returns:
- the value before adding
-
addAndGet
public final long addAndGet(int i, long delta) - Parameters:
i- the indexdelta- 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
-