class Atomic
pub class Atomic<T :: [AtomicValue]>
A value that every thread reads and writes in one step.
Each operation is sequentially consistent and orders the reads and writes around it: what a thread did before a store, a thread that loads what it stored sees.
Its operations are std.task's atomic operations on the place of value: an atomic is the
object around one word for a program that shares it — what holds such a word in a field of
its own needs no object.
Methods
pub static fn new(value: T): Atomic<T>
Creates an atomic that holds value.
pub fn load(): T
Returns the value.
pub mut fn store(value: T): void
Sets the value.
pub mut fn exchange(value: T): T
Sets the value and returns the one it replaced.
pub mut fn compareAndSet(expected: T, desired: T): bool
Sets the value to desired where it is expected, in one step, and returns whether it did.
Returns false, and changes nothing, where the value was another. A class is compared by
identity: the same object, whatever == says.
pub mut fn fetchAndAdd(n: int): int
Adds n and returns the value before. It wraps around, as +% does.
pub mut fn addAndFetch(n: int): int
Adds n and returns the value after. It wraps around, as +% does.