Trait Atomic

Source
pub trait Atomic<T>:
    Send
    + Sync
    + Sized
where T: Sized,
{ // Required methods fn new(val: T) -> Self; fn store(&self, val: T, order: Ordering); fn load(&self, order: Ordering) -> T; fn swap(&self, val: T, order: Ordering) -> T; fn get_mut(&mut self) -> &mut T; fn into_inner(self) -> T; fn compare_and_swap(&self, current: T, new: T, order: Ordering) -> T; fn compare_exchange( &self, current: T, new: T, success: Ordering, failure: Ordering, ) -> Result<T, T>; fn compare_exchange_weak( &self, current: T, new: T, success: Ordering, failure: Ordering, ) -> Result<T, T>; // Provided method unsafe fn from_raw(val: &T) -> &Self { ... } }
Expand description

Trait describing an atomic version of an atomically-sized type.

Required Methods§

Source

fn new(val: T) -> Self

Source

fn store(&self, val: T, order: Ordering)

Source

fn load(&self, order: Ordering) -> T

Source

fn swap(&self, val: T, order: Ordering) -> T

Source

fn get_mut(&mut self) -> &mut T

Source

fn into_inner(self) -> T

Source

fn compare_and_swap(&self, current: T, new: T, order: Ordering) -> T

Source

fn compare_exchange( &self, current: T, new: T, success: Ordering, failure: Ordering, ) -> Result<T, T>

Source

fn compare_exchange_weak( &self, current: T, new: T, success: Ordering, failure: Ordering, ) -> Result<T, T>

Provided Methods§

Source

unsafe fn from_raw(val: &T) -> &Self

Generate a reference to the atomic version of this type using its normal version.

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 Atomic<bool> for AtomicBool

Source§

fn new(val: bool) -> Self

Source§

fn store(&self, val: bool, order: Ordering)

Source§

fn load(&self, order: Ordering) -> bool

Source§

fn swap(&self, val: bool, order: Ordering) -> bool

Source§

fn get_mut(&mut self) -> &mut bool

Source§

fn into_inner(self) -> bool

Source§

fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool

Source§

fn compare_exchange( &self, current: bool, new: bool, success: Ordering, failure: Ordering, ) -> Result<bool, bool>

Source§

fn compare_exchange_weak( &self, current: bool, new: bool, success: Ordering, failure: Ordering, ) -> Result<bool, bool>

Source§

impl Atomic<i8> for AtomicI8

Source§

fn new(val: i8) -> Self

Source§

fn store(&self, val: i8, order: Ordering)

Source§

fn load(&self, order: Ordering) -> i8

Source§

fn swap(&self, val: i8, order: Ordering) -> i8

Source§

fn get_mut(&mut self) -> &mut i8

Source§

fn into_inner(self) -> i8

Source§

fn compare_and_swap(&self, current: i8, new: i8, order: Ordering) -> i8

Source§

fn compare_exchange( &self, current: i8, new: i8, success: Ordering, failure: Ordering, ) -> Result<i8, i8>

Source§

fn compare_exchange_weak( &self, current: i8, new: i8, success: Ordering, failure: Ordering, ) -> Result<i8, i8>

Source§

impl Atomic<i16> for AtomicI16

Source§

fn new(val: i16) -> Self

Source§

fn store(&self, val: i16, order: Ordering)

Source§

fn load(&self, order: Ordering) -> i16

Source§

fn swap(&self, val: i16, order: Ordering) -> i16

Source§

fn get_mut(&mut self) -> &mut i16

Source§

fn into_inner(self) -> i16

Source§

fn compare_and_swap(&self, current: i16, new: i16, order: Ordering) -> i16

Source§

fn compare_exchange( &self, current: i16, new: i16, success: Ordering, failure: Ordering, ) -> Result<i16, i16>

Source§

fn compare_exchange_weak( &self, current: i16, new: i16, success: Ordering, failure: Ordering, ) -> Result<i16, i16>

Source§

impl Atomic<i32> for AtomicI32

Source§

fn new(val: i32) -> Self

Source§

fn store(&self, val: i32, order: Ordering)

Source§

fn load(&self, order: Ordering) -> i32

Source§

fn swap(&self, val: i32, order: Ordering) -> i32

Source§

fn get_mut(&mut self) -> &mut i32

Source§

fn into_inner(self) -> i32

Source§

fn compare_and_swap(&self, current: i32, new: i32, order: Ordering) -> i32

Source§

fn compare_exchange( &self, current: i32, new: i32, success: Ordering, failure: Ordering, ) -> Result<i32, i32>

Source§

fn compare_exchange_weak( &self, current: i32, new: i32, success: Ordering, failure: Ordering, ) -> Result<i32, i32>

Source§

impl Atomic<i64> for AtomicI64

Source§

fn new(val: i64) -> Self

Source§

fn store(&self, val: i64, order: Ordering)

Source§

fn load(&self, order: Ordering) -> i64

Source§

fn swap(&self, val: i64, order: Ordering) -> i64

Source§

fn get_mut(&mut self) -> &mut i64

Source§

fn into_inner(self) -> i64

Source§

fn compare_and_swap(&self, current: i64, new: i64, order: Ordering) -> i64

Source§

fn compare_exchange( &self, current: i64, new: i64, success: Ordering, failure: Ordering, ) -> Result<i64, i64>

Source§

fn compare_exchange_weak( &self, current: i64, new: i64, success: Ordering, failure: Ordering, ) -> Result<i64, i64>

Source§

impl Atomic<isize> for AtomicIsize

Source§

fn new(val: isize) -> Self

Source§

fn store(&self, val: isize, order: Ordering)

Source§

fn load(&self, order: Ordering) -> isize

Source§

fn swap(&self, val: isize, order: Ordering) -> isize

Source§

fn get_mut(&mut self) -> &mut isize

Source§

fn into_inner(self) -> isize

Source§

fn compare_and_swap(&self, current: isize, new: isize, order: Ordering) -> isize

Source§

fn compare_exchange( &self, current: isize, new: isize, success: Ordering, failure: Ordering, ) -> Result<isize, isize>

Source§

fn compare_exchange_weak( &self, current: isize, new: isize, success: Ordering, failure: Ordering, ) -> Result<isize, isize>

Source§

impl Atomic<u8> for AtomicU8

Source§

fn new(val: u8) -> Self

Source§

fn store(&self, val: u8, order: Ordering)

Source§

fn load(&self, order: Ordering) -> u8

Source§

fn swap(&self, val: u8, order: Ordering) -> u8

Source§

fn get_mut(&mut self) -> &mut u8

Source§

fn into_inner(self) -> u8

Source§

fn compare_and_swap(&self, current: u8, new: u8, order: Ordering) -> u8

Source§

fn compare_exchange( &self, current: u8, new: u8, success: Ordering, failure: Ordering, ) -> Result<u8, u8>

Source§

fn compare_exchange_weak( &self, current: u8, new: u8, success: Ordering, failure: Ordering, ) -> Result<u8, u8>

Source§

impl Atomic<u16> for AtomicU16

Source§

fn new(val: u16) -> Self

Source§

fn store(&self, val: u16, order: Ordering)

Source§

fn load(&self, order: Ordering) -> u16

Source§

fn swap(&self, val: u16, order: Ordering) -> u16

Source§

fn get_mut(&mut self) -> &mut u16

Source§

fn into_inner(self) -> u16

Source§

fn compare_and_swap(&self, current: u16, new: u16, order: Ordering) -> u16

Source§

fn compare_exchange( &self, current: u16, new: u16, success: Ordering, failure: Ordering, ) -> Result<u16, u16>

Source§

fn compare_exchange_weak( &self, current: u16, new: u16, success: Ordering, failure: Ordering, ) -> Result<u16, u16>

Source§

impl Atomic<u32> for AtomicU32

Source§

fn new(val: u32) -> Self

Source§

fn store(&self, val: u32, order: Ordering)

Source§

fn load(&self, order: Ordering) -> u32

Source§

fn swap(&self, val: u32, order: Ordering) -> u32

Source§

fn get_mut(&mut self) -> &mut u32

Source§

fn into_inner(self) -> u32

Source§

fn compare_and_swap(&self, current: u32, new: u32, order: Ordering) -> u32

Source§

fn compare_exchange( &self, current: u32, new: u32, success: Ordering, failure: Ordering, ) -> Result<u32, u32>

Source§

fn compare_exchange_weak( &self, current: u32, new: u32, success: Ordering, failure: Ordering, ) -> Result<u32, u32>

Source§

impl Atomic<u64> for AtomicU64

Source§

fn new(val: u64) -> Self

Source§

fn store(&self, val: u64, order: Ordering)

Source§

fn load(&self, order: Ordering) -> u64

Source§

fn swap(&self, val: u64, order: Ordering) -> u64

Source§

fn get_mut(&mut self) -> &mut u64

Source§

fn into_inner(self) -> u64

Source§

fn compare_and_swap(&self, current: u64, new: u64, order: Ordering) -> u64

Source§

fn compare_exchange( &self, current: u64, new: u64, success: Ordering, failure: Ordering, ) -> Result<u64, u64>

Source§

fn compare_exchange_weak( &self, current: u64, new: u64, success: Ordering, failure: Ordering, ) -> Result<u64, u64>

Source§

impl Atomic<usize> for AtomicUsize

Source§

fn new(val: usize) -> Self

Source§

fn store(&self, val: usize, order: Ordering)

Source§

fn load(&self, order: Ordering) -> usize

Source§

fn swap(&self, val: usize, order: Ordering) -> usize

Source§

fn get_mut(&mut self) -> &mut usize

Source§

fn into_inner(self) -> usize

Source§

fn compare_and_swap(&self, current: usize, new: usize, order: Ordering) -> usize

Source§

fn compare_exchange( &self, current: usize, new: usize, success: Ordering, failure: Ordering, ) -> Result<usize, usize>

Source§

fn compare_exchange_weak( &self, current: usize, new: usize, success: Ordering, failure: Ordering, ) -> Result<usize, usize>

Source§

impl<T> Atomic<*mut T> for AtomicPtr<T>

Source§

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

Source§

fn store(&self, val: *mut T, order: Ordering)

Source§

fn load(&self, order: Ordering) -> *mut T

Source§

fn swap(&self, val: *mut T, order: Ordering) -> *mut T

Source§

fn get_mut(&mut self) -> &mut *mut T

Source§

fn into_inner(self) -> *mut T

Source§

fn compare_and_swap( &self, current: *mut T, new: *mut T, order: Ordering, ) -> *mut T

Source§

fn compare_exchange( &self, current: *mut T, new: *mut T, success: Ordering, failure: Ordering, ) -> Result<*mut T, *mut T>

Source§

fn compare_exchange_weak( &self, current: *mut T, new: *mut T, success: Ordering, failure: Ordering, ) -> Result<*mut T, *mut T>

Implementors§