addAndFetch

expect fun addAndFetch(delta: Long): Long(source)

Atomically adds the given value to the current value of this AtomicLong and returns the new value.

Since Kotlin

2.1

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread

fun main() { 
   //sampleStart 
   val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17 
   //sampleEnd
}
actual fun addAndFetch(delta: Long): Long(source)

Atomically adds the given value to the current value of this AtomicLong and returns the new value.

Since Kotlin

2.1
actual fun addAndFetch(delta: Long): Long(source)

Atomically adds the given value to the current value of this AtomicLong and returns the new value.

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

Since Kotlin

2.1
actual fun addAndFetch(delta: Long): Long(source)

Atomically adds the given value to the current value of this AtomicLong and returns the new value.

Since Kotlin

2.1
actual fun addAndFetch(delta: Long): Long(source)

Atomically adds the given value to the current value of this AtomicLong and returns the new value.

Since Kotlin

2.1
actual fun addAndFetch(delta: Long): Long(source)

Atomically adds the given value to the current value of this AtomicLong and returns the new value.

Since Kotlin

2.1