Scoop API

scoop:scoop.core:0.1.0

AtomicInt

class AtomicInt

source · line 35
public
public class AtomicInt

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 compareAndSet

source · line 57
public
@NoGC @Intrinsic("atomic_int_compare_and_set")
    public fun compareAndSet(expected: Int, value: Int, 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 100
public
public fun getAndUpdate(update: (Int) -> Int): Int

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 updateAndGet

source · line 114
public
public fun updateAndGet(update: (Int) -> Int): Int

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

function compareAndExchange

source · line 63
public
@NoGC @Intrinsic("atomic_int_compare_and_exchange")
    public fun compareAndExchange(expected: Int, value: Int, successOrder: MemoryOrder = MemoryOrder.SeqCst, failureOrder: MemoryOrder = MemoryOrder.SeqCst): Int

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