AtomicReference

An object reference that may be updated atomically.

Platform-specific implementation details:

When targeting the Native backend, AtomicReference stores a volatile variable of type T and atomically updates it. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

When targeting the JVM, instances of AtomicReference are represented by java.util.concurrent.atomic.AtomicReference. For details about guarantees of volatile accesses and updates of atomics refer to The Java Language Specification (17.4 Memory Model).

For JS and Wasm AtomicReference is implemented trivially and is not thread-safe since these platforms do not support multi-threading.

Since Kotlin

2.1

An object reference that may be updated atomically.

Since the JS platform does not support multi-threading, the implementation is trivial and has no atomic synchronizations.

Since Kotlin

2.1

An object reference that may be updated atomically.

Instances of AtomicReference are represented by java.util.concurrent.atomic.AtomicReference and provide the the same atomicity guarantees.

Since Kotlin

2.1

An object reference that may be updated atomically.

Read operation load has the same memory effects as reading a Volatile property; Write operation store has the same memory effects as writing a Volatile property; Read-modify-write operations, like exchange, compareAndSet, compareAndExchange, have the same memory effects as reading and writing a Volatile property.

For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin

2.1

An object reference that may be updated atomically.

Since the Wasm platform does not support multi-threading, the implementation is trivial and has no atomic synchronizations.

Since Kotlin

2.1

An object reference that may be updated atomically.

Since the Wasm platform does not support multi-threading, the implementation is trivial and has no atomic synchronizations.

Since Kotlin

2.1

Constructors

Link copied to clipboard
expect constructor(value: T)
actual constructor(value: T)
constructor(value: T)
actual constructor(value: T)
actual constructor(value: T)
actual constructor(value: T)

Properties

Link copied to clipboard
Since Kotlin 2.1

Functions

Link copied to clipboard
Link copied to clipboard
expect fun compareAndExchange(expectedValue: T, newValue: T): T

Atomically stores the given new value into this AtomicReference if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
actual fun compareAndExchange(expectedValue: T, newValue: T): T

Atomically stores the given new value into this AtomicReference if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
actual fun compareAndExchange(expectedValue: T, newValue: T): T

Atomically stores the given new value into this AtomicReference if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
actual fun compareAndExchange(expectedValue: T, newValue: T): T

Atomically stores the given new value into this AtomicReference if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
actual fun compareAndExchange(expectedValue: T, newValue: T): T

Atomically stores the given new value into this AtomicReference if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
actual fun compareAndExchange(expectedValue: T, newValue: T): T

Atomically stores the given new value into this AtomicReference if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
Link copied to clipboard
expect fun compareAndSet(expectedValue: T, newValue: T): Boolean

Atomically stores the given new value into this AtomicReference 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.

Since Kotlin 2.1
actual fun compareAndSet(expectedValue: T, newValue: T): Boolean

Atomically stores the given new value into this AtomicReference 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.

Since Kotlin 2.1
actual fun compareAndSet(expectedValue: T, newValue: T): Boolean

Atomically stores the given new value into this AtomicReference 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.

Since Kotlin 2.1
actual fun compareAndSet(expectedValue: T, newValue: T): Boolean

Atomically stores the given new value into this AtomicReference 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.

Since Kotlin 2.1
actual fun compareAndSet(expectedValue: T, newValue: T): Boolean

Atomically stores the given new value into this AtomicReference 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.

Since Kotlin 2.1
actual fun compareAndSet(expectedValue: T, newValue: T): Boolean

Atomically stores the given new value into this AtomicReference 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.

Since Kotlin 2.1
Link copied to clipboard
expect fun exchange(newValue: T): T

Atomically stores the given new value into this AtomicReference. and returns the old value.

Since Kotlin 2.1
actual fun exchange(newValue: T): T

Atomically stores the given new value into this AtomicReference and returns the old value.

Since Kotlin 2.1
actual fun exchange(newValue: T): T

Atomically stores the given new value into this AtomicReference and returns the old value.

Since Kotlin 2.1
actual fun exchange(newValue: T): T

Atomically stores the given new value into this AtomicReference and returns the old value.

Since Kotlin 2.1
actual fun exchange(newValue: T): T

Atomically stores the given new value into this AtomicReference and returns the old value.

Since Kotlin 2.1
actual fun exchange(newValue: T): T

Atomically stores the given new value into this AtomicReference and returns the old value.

Since Kotlin 2.1
Link copied to clipboard
fun getAndSet(newValue: T): T

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

Since Kotlin 2.1
Link copied to clipboard
expect fun load(): T

Atomically loads the value from this AtomicReference.

Since Kotlin 2.1
actual fun load(): T

Atomically loads the value from this AtomicReference.

Since Kotlin 2.1
actual fun load(): T

Atomically loads the value from this AtomicReference.

Since Kotlin 2.1
actual fun load(): T

Atomically loads the value from this AtomicReference.

Since Kotlin 2.1
actual fun load(): T

Atomically loads the value from this AtomicReference.

Since Kotlin 2.1
actual fun load(): T

Atomically loads the value from this AtomicReference.

Since Kotlin 2.1
Link copied to clipboard
expect fun store(newValue: T)

Atomically stores the new value into this AtomicReference.

Since Kotlin 2.1
actual fun store(newValue: T)

Atomically stores the new value into this AtomicReference.

Since Kotlin 2.1
actual fun store(newValue: T)

Atomically stores the new value into this AtomicReference.

Since Kotlin 2.1
actual fun store(newValue: T)

Atomically stores the new value into this AtomicReference.

Since Kotlin 2.1
actual fun store(newValue: T)

Atomically stores the new value into this AtomicReference.

Since Kotlin 2.1
actual fun store(newValue: T)

Atomically stores the new value into this AtomicReference.

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

Returns the string representation of the underlying object.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying object.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying object.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying object.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying object.

Since Kotlin 2.1
actual open override fun toString(): String

Returns the string representation of the underlying object.

Since Kotlin 2.1