compareAndSwap

fun compareAndSwap(expected: T, newValue: T): T(source)

Atomically sets the value to the given new value if the current value equals the expected value and returns the old value in any case.

Since Kotlin

1.3

Return

the old value

Parameters

expected

the expected value

newValue

the new value