AtomicIntArray

An IntArray 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

Constructors

Link copied to clipboard
constructor(size: Int)

Creates a new AtomicIntArray of the given size, with all elements initialized to zero.

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 addAndGet(index: Int, delta: Int): Int

Atomically adds the given delta to the element at the given index and returns the new value of the element.

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

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: Int, newValue: Int): 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
fun decrementAndGet(index: Int): Int

Atomically decrements the element at the given index by one and returns the new value of the element.

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

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

Since Kotlin 1.9
Link copied to clipboard
fun getAndAdd(index: Int, delta: Int): Int

Atomically adds the given delta to the element at the given index and returns the old value of the element.

Since Kotlin 1.9
Link copied to clipboard
fun getAndDecrement(index: Int): Int

Atomically decrements the element at the given index by one and returns the old value of the element.

Since Kotlin 1.9
Link copied to clipboard
fun getAndIncrement(index: Int): Int

Atomically increments the element at the given index by one and returns the old value of the element.

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

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
fun incrementAndGet(index: Int): Int

Atomically increments the element at the given index by one and returns the new value of the element.

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

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