Trait testbench::race_cell::AtomicLoadStore
source · [−]pub trait AtomicLoadStore: Sized {
type Content: AtomicData<AtomicWrapper = Self>;
fn new(v: Self::Content) -> Self;
fn relaxed_load(&self) -> Self::Content;
fn relaxed_store(&self, val: Self::Content);
}
Expand description
Atomic wrapper type for a certain kind of value
For the implementation of RaceCell not to be considered as undefined behaviour and trashed by the Rust compiler in release mode, the underlying type must be loaded and stored atomically. This requires synchronizing accesses to it using things like the std::sync::atomic::AtomicXyz wrappers.
The only guarantee that we need is that loads and stores are atomic. We do not need any other memory ordering guarantee. This is why we allow for more wrapper type implementation freedom by not specifying memory orderings, and internally relying only on relaxed ordering.
Required Associated Types
type Content: AtomicData<AtomicWrapper = Self>
type Content: AtomicData<AtomicWrapper = Self>
Type of data that is being wrapped
Required Methods
fn relaxed_load(&self) -> Self::Content
fn relaxed_load(&self) -> Self::Content
Atomically load a value from the wrapper
fn relaxed_store(&self, val: Self::Content)
fn relaxed_store(&self, val: Self::Content)
Atomically store a new value into the wrapper