AtomicReference

Platform and version requirements: Native (1.3)
class AtomicReference<T>

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.

Constructors

Platform and version requirements: Native (1.3)

<init>

Creates a new atomic reference pointing to given ref.

AtomicReference(value: T)

Properties

Platform and version requirements: Native (1.3)

value

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

var value: T

Functions

Platform and version requirements: 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
Platform and version requirements: Native (1.3)

compareAndSwap

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.

fun compareAndSwap(expected: T, new: T): T
Platform and version requirements: Native (1.3)

toString

Returns the string representation of this object.

fun toString(): String

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.concurrent/-atomic-reference/index.html