Package dev.gmitch215.bytebox.locks
Class AtomicReferenceArray<E>
java.lang.Object
dev.gmitch215.bytebox.locks.AtomicReferenceArray<E>
- Type Parameters:
E- the element type
java.util.concurrent.atomic.AtomicReferenceArray, which the class library does not carry
even though it carries AtomicReference.
One fiber runs at a time and none of these operations suspends, so each is already indivisible and no lock is needed to make it so.
- Since:
- 1.0.2
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
AtomicReferenceArray
public AtomicReferenceArray(int length) - Parameters:
length- how many elements, each starting null
-
AtomicReferenceArray
- Parameters:
array- the elements to copy
-
-
Method Details
-
length
public final int length()Returns how many elements.- Returns:
- how many elements
-
get
- Parameters:
i- the index- Returns:
- the element
-
set
- Parameters:
i- the indexnewValue- the element to store
-
lazySet
- Parameters:
i- the indexnewValue- the element to store
-
getAndSet
- Parameters:
i- the indexnewValue- the element to store- Returns:
- the element that was there
-
compareAndSet
- Parameters:
i- the indexexpect- the element that must be thereupdate- the element to store- Returns:
- whether it was stored
-
weakCompareAndSet
- Parameters:
i- the indexexpect- the element that must be thereupdate- the element to store- Returns:
- whether it was stored
-
toString
-