AtomicArray

A generic array of objects in which elements may be updated atomically.

Platform-specific implementation details:

When targeting the Native backend, AtomicArray stores an Array with elements of type T and atomically updates it's elements. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

When targeting the JVM, instances of AtomicArray are represented by java.util.concurrent.atomic.AtomicReferenceArray. For details about guarantees of volatile accesses and updates of atomics refer to The Java Language Specification (17.4 Memory Model).

For JS and Wasm AtomicArray is implemented trivially and is not thread-safe since these platforms do not support multi-threading.

Since Kotlin

2.1

A generic array of objects in which elements may be updated atomically.

Since the JS platform does not support multi-threading, the implementation is trivial and has no atomic synchronizations.

Since Kotlin

2.1

A generic array of objects in which elements may be updated atomically.

Instances of AtomicArray are represented by java.util.concurrent.atomic.AtomicReferenceArray and provide the the same atomicity guarantees.

Since Kotlin

2.1

A generic array of objects in which elements may be updated atomically.

Read operation loadAt has the same memory effects as reading a Volatile property; Write operation storeAt has the same memory effects as writing a Volatile property; Read-modify-write operations, like exchangeAt, compareAndSetAt, compareAndExchangeAt, have the same memory effects as reading and writing a Volatile property.

For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin

2.1

A generic array of objects in which elements may be updated atomically.

Since the Wasm platform does not support multi-threading, the implementation is trivial and has no atomic synchronizations.

Since Kotlin

2.1

A generic array of objects in which elements may be updated atomically.

Since the Wasm platform does not support multi-threading, the implementation is trivial and has no atomic synchronizations.

Since Kotlin

2.1

Constructors

Link copied to clipboard
expect constructor(array: Array<T>)

Creates a new AtomicArray filled with elements of the given array.

actual constructor(array: Array<T>)

Creates a new AtomicArray filled with elements of the given array.

actual constructor(array: Array<T>)

Creates a new AtomicArray filled with elements of the given array.

actual constructor(array: Array<T>)

Creates a new AtomicArray filled with elements of the given array.

actual constructor(array: Array<T>)

Creates a new AtomicArray filled with elements of the given array.

actual constructor(array: Array<T>)

Creates a new AtomicArray filled with elements of the given array.

Properties

Link copied to clipboard
val length: Int

Returns the number of elements in the array.

Since Kotlin 2.1
Link copied to clipboard
expect val size: Int

Returns the number of elements in the array.

Since Kotlin 2.1
actual val size: Int

Returns the number of elements in the array.

Since Kotlin 2.1
actual val size: Int

Returns the number of elements in the array.

Since Kotlin 2.1
actual val size: Int

Returns the number of elements in the array.

Since Kotlin 2.1
actual val size: Int

Returns the number of elements in the array.

Since Kotlin 2.1
actual val size: Int

Returns the number of elements in the array.

Since Kotlin 2.1

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 2.1
Link copied to clipboard
expect fun compareAndExchangeAt(index: Int, expectedValue: T, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 2.1
actual fun compareAndExchangeAt(index: Int, expectedValue: T, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 2.1
actual fun compareAndExchangeAt(index: Int, expectedValue: T, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 2.1
actual fun compareAndExchangeAt(index: Int, expectedValue: T, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 2.1
actual fun compareAndExchangeAt(index: Int, expectedValue: T, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 2.1
actual fun compareAndExchangeAt(index: Int, expectedValue: T, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index if the current value equals the expected value and returns the old value of the element in any case.

Since Kotlin 2.1
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 2.1
Link copied to clipboard
expect fun compareAndSetAt(index: Int, expectedValue: T, newValue: T): Boolean

Atomically stores the new value into the element of this AtomicArray at the given index 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 2.1
actual fun compareAndSetAt(index: Int, expectedValue: T, newValue: T): Boolean

Atomically stores the new value into the element of this AtomicArray at the given index 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 2.1
actual fun compareAndSetAt(index: Int, expectedValue: T, newValue: T): Boolean

Atomically stores the new value into the element of this AtomicArray at the given index 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 2.1
actual fun compareAndSetAt(index: Int, expectedValue: T, newValue: T): Boolean

Atomically stores the new value into the element of this AtomicArray at the given index 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 2.1
actual fun compareAndSetAt(index: Int, expectedValue: T, newValue: T): Boolean

Atomically stores the new value into the element of this AtomicArray at the given index 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 2.1
actual fun compareAndSetAt(index: Int, expectedValue: T, newValue: T): Boolean

Atomically stores the new value into the element of this AtomicArray at the given index 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 2.1
Link copied to clipboard
expect fun exchangeAt(index: Int, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.

Since Kotlin 2.1
actual fun exchangeAt(index: Int, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.

Since Kotlin 2.1
actual fun exchangeAt(index: Int, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.

Since Kotlin 2.1
actual fun exchangeAt(index: Int, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.

Since Kotlin 2.1
actual fun exchangeAt(index: Int, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.

Since Kotlin 2.1
actual fun exchangeAt(index: Int, newValue: T): T

Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.

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

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

Since Kotlin 2.1
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 2.1
Link copied to clipboard
expect fun loadAt(index: Int): T

Atomically loads the value from the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun loadAt(index: Int): T

Atomically loads the value from the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun loadAt(index: Int): T

Atomically loads the value from the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun loadAt(index: Int): T

Atomically loads the value from the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun loadAt(index: Int): T

Atomically loads the value from the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun loadAt(index: Int): T

Atomically loads the value from the element of this AtomicArray at the given index.

Since Kotlin 2.1
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 2.1
Link copied to clipboard
expect fun storeAt(index: Int, newValue: T)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun storeAt(index: Int, newValue: T)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun storeAt(index: Int, newValue: T)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun storeAt(index: Int, newValue: T)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun storeAt(index: Int, newValue: T)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin 2.1
actual fun storeAt(index: Int, newValue: T)

Atomically stores the new value into the element of this AtomicArray at the given index.

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

Returns the string representation of the underlying array of objects.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying array of objects.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying array of objects.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying array of objects.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying array of objects.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying array of objects.

Since Kotlin 2.1