Skip to main content

AtomicPrimitive

Trait AtomicPrimitive 

Source
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§

Source

type InnerPrimitive: Default

The primitive type that this atomic type is wrapping.

Required Methods§

Source

fn new(value: Self::InnerPrimitive) -> Self

Creates a new atomic wrapper with the given value.

Source

fn load(&self) -> Self::InnerPrimitive

Loads the value from the atomic wrapper.

Source

fn store(&self, value: Self::InnerPrimitive)

Stores the value into the atomic wrapper.

Provided Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl AtomicPrimitive for AtomicBool

Source§

type InnerPrimitive = bool

Source§

fn new(value: bool) -> Self

Source§

fn load(&self) -> bool

Source§

fn store(&self, value: bool)

Source§

impl AtomicPrimitive for AtomicI8

Source§

type InnerPrimitive = i8

Source§

fn new(value: i8) -> Self

Source§

fn load(&self) -> i8

Source§

fn store(&self, value: i8)

Source§

impl AtomicPrimitive for AtomicI16

Source§

type InnerPrimitive = i16

Source§

fn new(value: i16) -> Self

Source§

fn load(&self) -> i16

Source§

fn store(&self, value: i16)

Source§

impl AtomicPrimitive for AtomicI32

Source§

type InnerPrimitive = i32

Source§

fn new(value: i32) -> Self

Source§

fn load(&self) -> i32

Source§

fn store(&self, value: i32)

Source§

impl AtomicPrimitive for AtomicI64

Source§

type InnerPrimitive = i64

Source§

fn new(value: i64) -> Self

Source§

fn load(&self) -> i64

Source§

fn store(&self, value: i64)

Source§

impl AtomicPrimitive for AtomicIsize

Source§

type InnerPrimitive = isize

Source§

fn new(value: isize) -> Self

Source§

fn load(&self) -> isize

Source§

fn store(&self, value: isize)

Source§

impl AtomicPrimitive for AtomicU8

Source§

type InnerPrimitive = u8

Source§

fn new(value: u8) -> Self

Source§

fn load(&self) -> u8

Source§

fn store(&self, value: u8)

Source§

impl AtomicPrimitive for AtomicU16

Source§

type InnerPrimitive = u16

Source§

fn new(value: u16) -> Self

Source§

fn load(&self) -> u16

Source§

fn store(&self, value: u16)

Source§

impl AtomicPrimitive for AtomicU32

Source§

type InnerPrimitive = u32

Source§

fn new(value: u32) -> Self

Source§

fn load(&self) -> u32

Source§

fn store(&self, value: u32)

Source§

impl AtomicPrimitive for AtomicU64

Source§

type InnerPrimitive = u64

Source§

fn new(value: u64) -> Self

Source§

fn load(&self) -> u64

Source§

fn store(&self, value: u64)

Source§

impl AtomicPrimitive for AtomicUsize

Source§

type InnerPrimitive = usize

Source§

fn new(value: usize) -> Self

Source§

fn load(&self) -> usize

Source§

fn store(&self, value: usize)

Source§

impl<T> AtomicPrimitive for AtomicPtr<T>

Source§

type InnerPrimitive = *mut T

Source§

fn new(value: *mut T) -> Self

Source§

fn load(&self) -> *mut T

Source§

fn store(&self, value: *mut T)

Implementors§