pub trait AtomicPrimitive:
Sync
+ Send
+ Sized {
type InnerPrimitive: Default;
// Required methods
fn new(value: Self::InnerPrimitive) -> Self;
fn load(&self) -> Self::InnerPrimitive;
fn store(&self, value: Self::InnerPrimitive);
// Provided method
fn new_default() -> Self { ... }
}Expand description
Trait for atomic wrapper types used as the storage for controller payloads.
Types implementing this trait support atomic load and store of an inner primitive;
other operations and orderings are not used by the controller. Only payload types
that can be represented by such an atomic type are usable with SoftCycleController.
This trait is unrelated to the AtomicPrimitive trait in std::sync::atomic.
Required Associated Types§
Sourcetype InnerPrimitive: Default
type InnerPrimitive: Default
The primitive type that this atomic type is wrapping.
Required Methods§
Sourcefn new(value: Self::InnerPrimitive) -> Self
fn new(value: Self::InnerPrimitive) -> Self
Creates a new atomic wrapper with the given value.
Sourcefn load(&self) -> Self::InnerPrimitive
fn load(&self) -> Self::InnerPrimitive
Loads the value from the atomic wrapper.
Sourcefn store(&self, value: Self::InnerPrimitive)
fn store(&self, value: Self::InnerPrimitive)
Stores the value into the atomic wrapper.
Provided Methods§
Sourcefn new_default() -> Self
fn new_default() -> Self
Creates a new atomic wrapper with the default value of the primitive type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.