Scoop API

scoop:scoop.core:0.1.0

AtomicRef

class AtomicRef

source · line 314
public
public class AtomicRef<T : ref>

A shared atomic cell. Memory-order arguments must be compile-time enum variants. Loads permit Relaxed, Acquire, or SeqCst; stores permit Relaxed, Release, or SeqCst. Read-modify-write operations permit every order. Compare-exchange failure order cannot release or be stronger than success order. Reference comparison uses identity, not user-defined equality.

function updateAndGet

source · line 363
public
public fun updateAndGet(update: (T) -> T): T

Retries a compare-exchange loop and returns the installed value. The callback may run more than once.

function compareAndSet

source · line 336
public
@NoGC @Intrinsic("atomic_ref_compare_and_set")
    public fun compareAndSet(expected: T, value: T, successOrder: MemoryOrder = MemoryOrder.SeqCst, failureOrder: MemoryOrder = MemoryOrder.SeqCst): Boolean

Replaces the value only when it matches expected, returning whether replacement occurred.

function getAndUpdate

source · line 349
public
public fun getAndUpdate(update: (T) -> T): T

Retries a compare-exchange loop and returns the old value. The callback may run more than once; callback side effects are not rolled back.

function compareAndExchange

source · line 342
public
@NoGC @Intrinsic("atomic_ref_compare_and_exchange")
    public fun compareAndExchange(expected: T, value: T, successOrder: MemoryOrder = MemoryOrder.SeqCst, failureOrder: MemoryOrder = MemoryOrder.SeqCst): T

Conditionally replaces the value and returns the value observed by the comparison.