FreezableAtomicReference

Native
1.3
class FreezableAtomicReference<T>

An atomic reference to a Kotlin object. Can be used in concurrent scenarious, but must be frozen first, otherwise behaves as regular box for the value. If frozen, shall be zeroed out once no longer needed. Otherwise memory leak could happen if atomic reference is a part of a reference cycle.

Constructors

Native
1.3

<init>

An atomic reference to a Kotlin object. Can be used in concurrent scenarious, but must be frozen first, otherwise behaves as regular box for the value. If frozen, shall be zeroed out once no longer needed. Otherwise memory leak could happen if atomic reference is a part of a reference cycle.

FreezableAtomicReference(value_: T)

Properties

Native
1.3

value

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

var value: T

Functions

Native
1.3

compareAndSet

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

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

compareAndSwap

Compares value with expected and replaces it with new value if values matches. If new value is not null and object is frozen, it must be frozen or permanent object.

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

toString

Returns the string representation of this object.

fun toString(): String