4.90. kink/thread/ATOMIC

Provides atomic operations including compare-and-set.

4.90.1. ATOMIC.is?(Val)

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

4.90.2. ATOMIC.new(Initial_val)

Makes a new atomic with Initial_val as the initial val.

4.90.3. Type atomic

An atomic reference.

4.90.3.1. Atomic.get

Returns the val of the Atomic reference.

4.90.3.2. Atomic.set(New_val)

Sets New_val as the new val of the Atomic reference.

4.90.3.3. 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.

4.90.3.4. Atomic.update($compute_next)

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.