Scoop API

scoop:scoop.core:0.1.0

AtomicLong

class AtomicLong

source · line 132
public
public class AtomicLong

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.

function getAndUpdate

source · line 197
public
public fun getAndUpdate(update: (Long) -> Long): Long

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 160
public
@NoGC @Intrinsic("atomic_long_compare_and_exchange")
    public fun compareAndExchange(expected: Long, value: Long, successOrder: MemoryOrder = MemoryOrder.SeqCst, failureOrder: MemoryOrder = MemoryOrder.SeqCst): Long

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

function compareAndSet

source · line 154
public
@NoGC @Intrinsic("atomic_long_compare_and_set")
    public fun compareAndSet(expected: Long, value: Long, successOrder: MemoryOrder = MemoryOrder.SeqCst, failureOrder: MemoryOrder = MemoryOrder.SeqCst): Boolean

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