3.81. kink/thread/ATOMIC

Provides atomic operations including compare-and-set.

3.81.1. ATOMIC.is?(Val)

ATOMIC.is? returns whether the Val is an atomic reference.

3.81.2. ATOMIC.new(Initial_val)

Makes a new atomic with Initial_val as the initial val.

3.81.3. Type atomic

An atomic reference.


Returns the val of the Atomic reference.


Sets New_val as the new val of the Atomic reference.

Atomic.compare_and_set(Expected Next)

Atomically sets the Next val to the Atomic reference, only if the current val is identical to Expected.

Returns whether the val could be set.


Atomically updates the val of the Atomic reference, and returns a pair of [Old New], where Old is the val just before the update, and New is the val just after the update.

The New val is computed by compute_next(Old), where Old is the current val of the Atomic reference. $compute_next may be invoked multiple times, thus it must not have side-effect.