addAndFetchAt

expect fun addAndFetchAt(index: Int, delta: Int): Int(source)

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

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*

fun main() { 
   //sampleStart 
   val a = AtomicIntArray(intArrayOf(1, 2, 3))
// Returns the new value after the addition.
println(a.addAndFetchAt(1, 10)) // 12
println(a.loadAt(1)) // 12
println(a.toString()) // [1, 12, 3] 
   //sampleEnd
}
actual fun addAndFetchAt(index: Int, delta: Int): Int(source)

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

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun addAndFetchAt(index: Int, delta: Int): Int(source)

Atomically adds the given delta the element of this AtomicIntArray at the given index by and returns the new value of the element.

Has the same memory effects as java.util.concurrent.atomic.AtomicIntegerArray.addAndGet.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun addAndFetchAt(index: Int, delta: Int): Int(source)

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

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun addAndFetchAt(index: Int, delta: Int): Int(source)

Atomically adds the given delta the element of this AtomicIntArray at the given index by and returns the new value of the element.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun addAndFetchAt(index: Int, delta: Int): Int(source)

Atomically adds the given delta the element of this AtomicIntArray at the given index by and returns the new value of the element.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.