AtomicReference

Native
1.3
@DeprecatedSinceKotlin("1.9") class AtomicReference<T>
(source)
Deprecated: Use kotlin.concurrent.AtomicReference instead.

An object reference that is always updated atomically.

Legacy MM: An atomic reference to a frozen Kotlin object. Can be used in concurrent scenarious but frequently shall be of nullable type and be zeroed out once no longer needed. Otherwise memory leak could happen. To detect such leaks kotlin.native.runtime.GC.detectCycles in debug mode could be helpful.

Constructors

Native
1.3

<init>

Creates a new atomic reference pointing to the given value.

AtomicReference(value: T)

Properties

Native
1.3

value

The current value. Gets the current value or sets to the given new value.

var value: T

Functions

Native
1.3

compareAndSet

Atomically sets the value to the given new value if the current value equals the expected value, returns true if the operation was successful and false only if the current value was not equal to the expected value.

fun compareAndSet(expected: T, newValue: T): Boolean
Native
1.3

compareAndSwap

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.

fun compareAndSwap(expected: T, newValue: T): T
Native
1.3

getAndSet

Atomically sets the value to the given new value and returns the old value.

fun getAndSet(newValue: T): T
Native
1.3

toString

Returns the string representation of this object.

fun toString(): String