Enum sync::atomics::Ordering[src]

pub enum Ordering {
    Relaxed,
    Release,
    Acquire,
    AcqRel,
    SeqCst,
}

Atomic memory orderings

Memory orderings limit the ways that both the compiler and CPU may reorder instructions around atomic operations. At its most restrictive, "sequentially consistent" atomics allow neither reads nor writes to be moved either before or after the atomic operation; on the other end "relaxed" atomics allow all reorderings.

Rust's memory orderings are the same as in C++[1].

1: http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync

Variants

Relaxed

No ordering constraints, only atomic operations

Release

When coupled with a store, all previous writes become visible to another thread that performs a load with Acquire ordering on the same value

Acquire

When coupled with a load, all subsequent loads will see data written before a store with Release ordering on the same value in another thread

AcqRel

When coupled with a load, uses Acquire ordering, and with a store Release ordering

SeqCst

Like AcqRel with the additional guarantee that all threads see all sequentially consistent operations in the same order.