The element at given index, with volatile read semantics
The element at given index, with volatile read semantics
Returns true iff previous value was expected, elem installed
The length of the array
The length of the array
Atomic swap of the element at index
Update element at given index, with volatile write semantics
Update element at given index, with volatile write semantics
Clones this object, including the underlying Array.
Clones this object, including the underlying Array.
Retries compareAndSet until success, using f, then returns the old value
Retries compareAndSet until success, using f, then returns the old value
(Changed in version 2.9.0) The behavior of scanRight
has changed. The previous behavior can be reproduced with scanRight.reverse.
(Changed in version 2.9.0) transpose
throws an IllegalArgumentException
if collections are not uniformly sized.
AtomicArray
implements a fixed-length indexed sequence where reads and writes have volatile semantics. In addition, it adds an atomic swap operation (swap
) and an atomic compare-and-swap (compareAndSet
). The collection is backed by one of the Java atomic array classes, with the best match chosen at construction time using a manifest.Instances of
AtomicArray[T]
are backed byAtomicIntegerArray
ifT
is a primitive of at most 32 bits (smaller values are padded rather than packed).AtomicArray[Long]
andAtomicArray[Double]
are backed byAtomicLongArray
. All other instances ofAtomicArray[T]
are backed byAtomicReferenceArray
(except forAtomicArray[Unit]
). Floats and doubles are stored using their raw bit representation.This class is used in the implementation of the reference STM implementation, but it is standalone and may be generally useful.