AtomicReference

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.internal.GC.detectCycles in debug mode could be helpful.

Since Kotlin

1.3

Constructors

Link copied to clipboard
constructor(value: T)

Creates a new atomic reference pointing to given ref.

Properties

Link copied to clipboard
var value: T

The referenced value. Gets the value or sets the new value. If new value is not null, it must be frozen or permanent object.

Since Kotlin 1.3

Functions

Link copied to clipboard
external fun compareAndSet(expected: T, new: T): Boolean

Compares value with expected and replaces it with new value if values matches. Note that comparison is identity-based, not value-based.

Since Kotlin 1.3
Link copied to clipboard
external fun compareAndSwap(expected: T, new: T): T

Compares value with expected and replaces it with new value if values matches. Note that comparison is identity-based, not value-based. If new value is not null, it must be frozen or permanent object.

Since Kotlin 1.3
Link copied to clipboard
open override fun toString(): String

Returns the string representation of this object.

Since Kotlin 1.3