pub struct AtomicU64(/* private fields */);
Expand description
Mock implementation of std::sync::atomic::AtomicU64
.
NOTE: Unlike std::sync::atomic::AtomicU64
, this type has a different in-memory representation than u64
.
Implementations§
source§impl AtomicU64
impl AtomicU64
sourcepub fn with_mut<R>(&mut self, f: impl FnOnce(&mut u64) -> R) -> R
pub fn with_mut<R>(&mut self, f: impl FnOnce(&mut u64) -> R) -> R
Get access to a mutable reference to the inner value.
sourcepub unsafe fn unsync_load(&self) -> u64
pub unsafe fn unsync_load(&self) -> u64
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) -> u64
pub fn into_inner(self) -> u64
Consumes the atomic and returns the contained value.
sourcepub fn swap(&self, val: u64, order: Ordering) -> u64
pub fn swap(&self, val: u64, order: Ordering) -> u64
Stores a value into the atomic integer, returning the previous value.
sourcepub fn compare_and_swap(&self, current: u64, new: u64, order: Ordering) -> u64
pub fn compare_and_swap(&self, current: u64, new: u64, order: Ordering) -> u64
Stores a value into the atomic integer if the current value is the same as the current
value.
sourcepub fn compare_exchange(
&self,
current: u64,
new: u64,
success: Ordering,
failure: Ordering
) -> Result<u64, u64>
pub fn compare_exchange( &self, current: u64, new: u64, success: Ordering, failure: Ordering ) -> Result<u64, u64>
Stores a value into the atomic if the current value is the same as the current
value.
sourcepub fn compare_exchange_weak(
&self,
current: u64,
new: u64,
success: Ordering,
failure: Ordering
) -> Result<u64, u64>
pub fn compare_exchange_weak( &self, current: u64, new: u64, success: Ordering, failure: Ordering ) -> Result<u64, u64>
Stores a value into the atomic if the current value is the same as the current value.
sourcepub fn fetch_add(&self, val: u64, order: Ordering) -> u64
pub fn fetch_add(&self, val: u64, order: Ordering) -> u64
Adds to the current value, returning the previous value.
sourcepub fn fetch_sub(&self, val: u64, order: Ordering) -> u64
pub fn fetch_sub(&self, val: u64, order: Ordering) -> u64
Subtracts from the current value, returning the previous value.
sourcepub fn fetch_and(&self, val: u64, order: Ordering) -> u64
pub fn fetch_and(&self, val: u64, order: Ordering) -> u64
Bitwise “and” with the current value.
sourcepub fn fetch_nand(&self, val: u64, order: Ordering) -> u64
pub fn fetch_nand(&self, val: u64, order: Ordering) -> u64
Bitwise “nand” with the current value.
sourcepub fn fetch_xor(&self, val: u64, order: Ordering) -> u64
pub fn fetch_xor(&self, val: u64, order: Ordering) -> u64
Bitwise “xor” with the current value.
sourcepub fn fetch_max(&self, val: u64, order: Ordering) -> u64
pub fn fetch_max(&self, val: u64, order: Ordering) -> u64
Stores the maximum of the current and provided value, returning the previous value
sourcepub fn fetch_min(&self, val: u64, order: Ordering) -> u64
pub fn fetch_min(&self, val: u64, order: Ordering) -> u64
Stores the minimum of the current and provided value, returning the previous value