fetchAndAddAt

expect fun fetchAndAddAt(index: Int, delta: Long): Long(source)

Atomically adds the given delta to the element of this AtomicLongArray at the given index and returns the old 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 = AtomicLongArray(longArrayOf(1, 2, 3))
// Returns the old value before the addition.
println(a.fetchAndAddAt(1, 10)) // 2
println(a.loadAt(1)) // 12
println(a.toString()) // [1, 12, 3] 
   //sampleEnd
}
actual fun fetchAndAddAt(index: Int, delta: Long): Long(source)

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

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun fetchAndAddAt(index: Int, delta: Long): Long(source)

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

Has the same memory effects as java.util.concurrent.atomic.AtomicLongArray.getAndAdd.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun fetchAndAddAt(index: Int, delta: Long): Long(source)

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

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun fetchAndAddAt(index: Int, delta: Long): Long(source)

Atomically adds the given delta the element of this AtomicLongArray at the given index by and returns the old value of the element.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

actual fun fetchAndAddAt(index: Int, delta: Long): Long(source)

Atomically adds the given delta the element of this AtomicLongArray at the given index by and returns the old value of the element.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.