rasa/atomic
Atomic integers backed by Erlang’s atomics. Each Atomic is a
single signed 64-bit integer. Atomics use atomic hardware instructions
without software locking.
Types
Values
pub fn add_get(atomic: Atomic, value: Int) -> Int
Atomically adds the given value to the atomic and returns the result.
pub fn compare_exchange(
atomic: Atomic,
expected: Int,
desired: Int,
) -> Result(Nil, Int)
Atomically compares the atomic with expected, and if equal, sets it to
desired. Returns Ok(Nil) if the swap succeeded, or Error(actual)
with the actual value if it did not match expected.
pub fn exchange(atomic: Atomic, value: Int) -> Int
Atomically replaces the value of the atomic with the given value and returns the previous value.