class

AtomicRef

@Js
const class AtomicRef : Obj

AtomicRef is used to manage a object reference shared between actor/threads with atomic updates. Only immutable objects may be shared.

constructors make

Construct with initial value

fields val

The current value

methods toStr

Return val.toStr

compareAndSet

Atomically set the value to update if current value is equivalent to the expect value compared using === operator

getAndSet

Atomically set the value and return the previous value

compareAndSet Bool compareAndSet(Obj? expect, Obj? update)

Atomically set the value to update if current value is equivalent to the expect value compared using === operator. Return true if updated, or false if current value was not equal to the expected value. Throw NotImmutableErr if update is mutable.

getAndSet Obj? getAndSet(Obj? val)

Atomically set the value and return the previous value. Throw NotImmutableErr if val is mutable.

make new make(Obj? val)

Construct with initial value. Throw NotImmutableErr if initialized to a mutable value.

toStr virtual Str toStr()

Return val.toStr

val Obj? : val

The current value. Throw NotImmutableErr if set to a mutable value.

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST