AtomicRef

expect class AtomicRef<V>(initialValue: V)

Deprecated

arrow.continuation is being discontinued and will be removed in the next version in favor of the Effect/ EagerEffect Runtime. If you depend on low-level APIs as in arrow.continuation, feel free to write us in the Kotlin Slack channel for guidance. The AtomicRef APIs have been moved to arrow.core.generic

Replace with

import arrow.core.generic.AtomicRef
AtomicRef<V>
actual class AtomicRef<V>(initialValue: V)

Deprecated

arrow.continuation is being discontinued and will be removed in the next version in favor of the Effect/ EagerEffect Runtime. If you depend on low-level APIs as in arrow.continuation, feel free to write us in the Kotlin Slack channel for guidance.

actual typealias AtomicRef = AtomicReference<V>
actual class AtomicRef<V>(initialValue: V)

Deprecated

arrow.continuation is being discontinued and will be removed in the next version in favor of the Effect/ EagerEffect Runtime. If you depend on low-level APIs as in arrow.continuation, feel free to write us in the Kotlin Slack channel for guidance.

Constructors

Link copied to clipboard
expect fun <V> AtomicRef(initialValue: V)
actual fun <V> AtomicRef(initialValue: V)
actual fun <V> AtomicRef(initialValue: V)

Functions

Link copied to clipboard
expect fun compareAndSet(expected: V, new: V): Boolean

Compare current value with expected and set to new if they're the same. Note, 'compare' is checking the actual object id, not 'equals'.

actual fun compareAndSet(expected: V, new: V): Boolean

Compare current value with expected and set to new if they're the same. Note, 'compare' is checking the actual object id, not 'equals'.

actual fun compareAndSet(expected: V, new: V): Boolean

Compare current value with expected and set to new if they're the same. Note, 'compare' is checking the actual object id, not 'equals'.

Link copied to clipboard
expect fun get(): V
actual fun get(): V
actual fun get(): V
Link copied to clipboard
expect fun getAndSet(value: V): V
actual fun getAndSet(value: V): V
actual fun getAndSet(value: V): V
Link copied to clipboard
expect fun set(value: V)
actual fun set(value: V)
actual fun set(value: V)

Extensions

Link copied to clipboard
inline fun <V> AtomicRef<V>.getAndUpdate(function: (V) -> V): V

Updates variable atomically using the specified function of its value and returns its old value.

Link copied to clipboard
inline fun <V> AtomicRef<V>.loop(action: (V) -> Unit): Nothing

Infinite loop that reads this atomic variable and performs the specified action on its value.

Link copied to clipboard
inline fun <V> AtomicRef<V>.update(function: (V) -> V)
Link copied to clipboard
inline fun <V> AtomicRef<V>.updateAndGet(function: (V) -> V): V

Updates variable atomically using the specified function of its value and returns its new value.