pub enum MemOrder {
NotAtomic,
Relaxed,
Acquire,
Release,
AcqRel,
SeqCst,
}Expand description
How strongly an atomic operation is ordered against everything around it.
These are C11’s, minus consume, which every compiler in existence widens to acquire
because nobody can implement it as specified and the standard committee has said so.
Variants§
NotAtomic
Not atomic at all, which is what an ordinary load or store is.
Relaxed
Atomic, with no ordering against anything else.
Acquire
Nothing after this in program order moves before it.
Release
Nothing before this in program order moves after it.
AcqRel
Both, for a read-modify-write.
SeqCst
Both, and a single total order over every sequentially consistent operation.
Implementations§
Source§impl MemOrder
impl MemOrder
Sourcepub const fn is_valid_for_load(self) -> bool
pub const fn is_valid_for_load(self) -> bool
Whether this ordering can be asked of a load.
A load cannot release, because there is nothing it published.
Sourcepub const fn is_valid_for_store(self) -> bool
pub const fn is_valid_for_store(self) -> bool
Whether this ordering can be asked of a store.
A store cannot acquire, because it read nothing to synchronise with.
Sourcepub const fn is_valid_for_rmw(self) -> bool
pub const fn is_valid_for_rmw(self) -> bool
Whether this ordering can be asked of a read-modify-write, which is any of them.
Sourcepub const fn is_release(self) -> bool
pub const fn is_release(self) -> bool
Whether this ordering publishes everything before it, which is the release half.
Asked by the race detector rather than by the back end. A release is a synchronization edge
in the sense of spec/safe-memory/09-type-init-and-races.md section 9.5, so it is where a
thread’s clock has to be written down for whoever takes the other end.
Sourcepub const fn is_acquire(self) -> bool
pub const fn is_acquire(self) -> bool
Whether this ordering takes everything published before it, which is the acquire half.
The other end of MemOrder::is_release. acq_rel and seq_cst answer yes to both, which
is what makes a read-modify-write one edge in and one edge out.