Struct loom::sync::atomic::AtomicUsize
source · pub struct AtomicUsize(/* private fields */);
Expand description
Mock implementation of std::sync::atomic::AtomicUsize
.
NOTE: Unlike std::sync::atomic::AtomicUsize
, this type has a different in-memory representation than usize
.
Implementations§
source§impl AtomicUsize
impl AtomicUsize
sourcepub fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R
pub fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R
Get access to a mutable reference to the inner value.
sourcepub unsafe fn unsync_load(&self) -> usize
pub unsafe fn unsync_load(&self) -> usize
Load the value without any synchronization.
§Safety
An unsynchronized atomic load technically always has undefined behavior. However, if the atomic value is not currently visible by other threads, this should always be equivalent to a non-atomic load of an un-shared integer value.
sourcepub fn into_inner(self) -> usize
pub fn into_inner(self) -> usize
Consumes the atomic and returns the contained value.
sourcepub fn swap(&self, val: usize, order: Ordering) -> usize
pub fn swap(&self, val: usize, order: Ordering) -> usize
Stores a value into the atomic integer, returning the previous value.
sourcepub fn compare_and_swap(
&self,
current: usize,
new: usize,
order: Ordering
) -> usize
pub fn compare_and_swap( &self, current: usize, new: usize, order: Ordering ) -> usize
Stores a value into the atomic integer if the current value is the same as the current
value.
sourcepub fn compare_exchange(
&self,
current: usize,
new: usize,
success: Ordering,
failure: Ordering
) -> Result<usize, usize>
pub fn compare_exchange( &self, current: usize, new: usize, success: Ordering, failure: Ordering ) -> Result<usize, usize>
Stores a value into the atomic if the current value is the same as the current
value.
sourcepub fn compare_exchange_weak(
&self,
current: usize,
new: usize,
success: Ordering,
failure: Ordering
) -> Result<usize, usize>
pub fn compare_exchange_weak( &self, current: usize, new: usize, success: Ordering, failure: Ordering ) -> Result<usize, usize>
Stores a value into the atomic if the current value is the same as the current value.
sourcepub fn fetch_add(&self, val: usize, order: Ordering) -> usize
pub fn fetch_add(&self, val: usize, order: Ordering) -> usize
Adds to the current value, returning the previous value.
sourcepub fn fetch_sub(&self, val: usize, order: Ordering) -> usize
pub fn fetch_sub(&self, val: usize, order: Ordering) -> usize
Subtracts from the current value, returning the previous value.
sourcepub fn fetch_and(&self, val: usize, order: Ordering) -> usize
pub fn fetch_and(&self, val: usize, order: Ordering) -> usize
Bitwise “and” with the current value.
sourcepub fn fetch_nand(&self, val: usize, order: Ordering) -> usize
pub fn fetch_nand(&self, val: usize, order: Ordering) -> usize
Bitwise “nand” with the current value.
sourcepub fn fetch_or(&self, val: usize, order: Ordering) -> usize
pub fn fetch_or(&self, val: usize, order: Ordering) -> usize
Bitwise “or” with the current value.
sourcepub fn fetch_xor(&self, val: usize, order: Ordering) -> usize
pub fn fetch_xor(&self, val: usize, order: Ordering) -> usize
Bitwise “xor” with the current value.
sourcepub fn fetch_max(&self, val: usize, order: Ordering) -> usize
pub fn fetch_max(&self, val: usize, order: Ordering) -> usize
Stores the maximum of the current and provided value, returning the previous value
sourcepub fn fetch_min(&self, val: usize, order: Ordering) -> usize
pub fn fetch_min(&self, val: usize, order: Ordering) -> usize
Stores the minimum of the current and provided value, returning the previous value