AtomicArray

An Array in which elements are always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin

1.9

Properties

Link copied to clipboard
val length: Int

Returns the number of elements in the array.

Since Kotlin 1.9

Functions

Link copied to clipboard
fun compareAndExchange(index: Int, expectedValue: T, newValue: T): T

Atomically sets the value of the element at the given index to the new value if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 1.9
Link copied to clipboard
fun compareAndSet(index: Int, expectedValue: T, newValue: T): Boolean

Atomically sets the value of the element at the given index to the new value if the current value equals the expected value. Returns true if the operation was successful and false only if the current value of the element was not equal to the expected value.

Since Kotlin 1.9
Link copied to clipboard
operator fun get(index: Int): T

Atomically gets the value of the element at the given index.

Since Kotlin 1.9
Link copied to clipboard
fun getAndSet(index: Int, newValue: T): T

Atomically sets the value of the element at the given index to the new value and returns the old value of the element.

Since Kotlin 1.9
Link copied to clipboard
operator fun set(index: Int, newValue: T)

Atomically sets the value of the element at the given index to the new value.

Since Kotlin 1.9
Link copied to clipboard
open override fun toString(): String

Returns the string representation of the underlying IntArray.

Since Kotlin 1.9