#[repr(u32)]pub enum MemoryOrdering {
Relaxed = 0,
ReleaseAcquire = 1,
SequentiallyConsistent = 2,
}
Expand description
An enum of memory ordering possibilities for atomics.
Memory ordering is the observable state of distinct values in memory. (It’s a separate concept from atomicity, which concerns whether an operation can ever be observed in an intermediate state. Don’t conflate the two!) Given a sequence of operations in source code on memory, it is not always the case that, at all times and on all cores, those operations will appear to have occurred in that exact sequence. First, the compiler might reorder that sequence, if it thinks another ordering will be more efficient. Second, the CPU may not expose so consistent a view of memory. CPUs will often perform their own instruction reordering, above and beyond that performed by the compiler. And each core has its own memory caches, and accesses (reads and writes both) to “memory” may only resolve to out-of-date cache entries – not to the “most recently” performed operation in some global sense. Any access to a value that may be used by multiple threads, potentially across multiple cores, must therefore have a memory ordering imposed on it, for all code on all threads/cores to have a sufficiently coherent worldview.
http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and http://en.cppreference.com/w/cpp/atomic/memory_order go into more detail on all this, including examples of how each mode works.
Note that for simplicity and practicality, not all of the modes in C++11 are supported. The missing C++11 modes are either subsumed by the modes we provide below, or not relevant for the CPUs we support in Gecko. These three modes are confusing enough as it is!
Variants§
Trait Implementations§
source§impl Clone for MemoryOrdering
impl Clone for MemoryOrdering
source§fn clone(&self) -> MemoryOrdering
fn clone(&self) -> MemoryOrdering
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MemoryOrdering
impl Debug for MemoryOrdering
source§impl Hash for MemoryOrdering
impl Hash for MemoryOrdering
source§impl PartialEq for MemoryOrdering
impl PartialEq for MemoryOrdering
impl Copy for MemoryOrdering
impl Eq for MemoryOrdering
impl StructuralPartialEq for MemoryOrdering
Auto Trait Implementations§
impl Freeze for MemoryOrdering
impl RefUnwindSafe for MemoryOrdering
impl Send for MemoryOrdering
impl Sync for MemoryOrdering
impl Unpin for MemoryOrdering
impl UnwindSafe for MemoryOrdering
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more