const class concurrent::AtomicRef
sys::Obj concurrent::AtomicRef
@Js
AtomicRef is used to manage a object reference shared between actor/threads with atomic updates. Only immutable objects may be shared.
- compareAndSet
-
Bool compareAndSet(Obj? expect, Obj? update)Atomically set the value to
updateif current value is equivalent to theexpectvalue compared using===operator. Return true if updated, or false if current value was not equal to the expected value. Throw NotImmutableErr ifupdateis mutable. - getAndSet
-
Atomically set the value and return the previous value. Throw NotImmutableErr if
valis mutable. - make
-
new make(Obj? val := null)Construct with initial value. Throw NotImmutableErr if initialized to a mutable value.
- toStr
-
virtual override Str toStr()Return
val.toStr - val
-
Obj? valThe current value. Throw NotImmutableErr if set to a mutable value.