pub struct AtomicFallback { /* private fields */ }
doc
only.Expand description
An example fallback implementation of an atomic integer.
When no built-in atomic for a certain integer type is available, its type
alias in this crate points to a type like this, except with methods that
take and return that integer type, rather than i32
.
This type internally uses spinlocks, which can cause deadlocks with signal
handlers. To avoid this, enable the feature signal
, which blocks incoming
signals while the spinlock is held.
The API of this type is designed to be compatible with the atomic integer
types in core::sync::atomic
.
This type is exposed only in the documentation for illustrative purposes.
Implementations§
Source§impl AtomicFallback
impl AtomicFallback
Sourcepub const fn new(v: i32) -> Self
pub const fn new(v: i32) -> Self
Creates a new atomic.
See, e.g., atomic::AtomicI32::new
.
Sourcepub fn get_mut(&mut self) -> &mut i32
pub fn get_mut(&mut self) -> &mut i32
Returns a mutable reference to the underlying value.
See, e.g., atomic::AtomicI32::get_mut
.
Sourcepub fn into_inner(self) -> i32
pub fn into_inner(self) -> i32
Consumes the atomic and returns the contained value.
See, e.g., atomic::AtomicI32::into_inner
.
Sourcepub fn load(&self, order: Ordering) -> i32
pub fn load(&self, order: Ordering) -> i32
Loads a value from the atomic.
See, e.g., atomic::AtomicI32::load
.
Sourcepub fn store(&self, val: i32, order: Ordering)
pub fn store(&self, val: i32, order: Ordering)
Stores a value into the atomic.
See, e.g., atomic::AtomicI32::store
.
Sourcepub fn swap(&self, val: i32, order: Ordering) -> i32
pub fn swap(&self, val: i32, order: Ordering) -> i32
Stores a value into the atomic, returning the previous value.
See, e.g., atomic::AtomicI32::swap
.
Sourcepub fn compare_and_swap(&self, current: i32, new: i32, order: Ordering) -> i32
pub fn compare_and_swap(&self, current: i32, new: i32, order: Ordering) -> i32
Stores a value into the atomic if the current value is the same
as the current
value.
See, e.g., atomic::AtomicI32::compare_and_swap
.
Sourcepub fn compare_exchange(
&self,
current: i32,
new: i32,
success: Ordering,
failure: Ordering,
) -> Result<i32, i32>
pub fn compare_exchange( &self, current: i32, new: i32, success: Ordering, failure: Ordering, ) -> Result<i32, i32>
Stores a value into the atomic if the current value is the same
as the current
value.
See, e.g., atomic::AtomicI32::compare_exchange
.
Sourcepub fn compare_exchange_weak(
&self,
current: i32,
new: i32,
success: Ordering,
failure: Ordering,
) -> Result<i32, i32>
pub fn compare_exchange_weak( &self, current: i32, new: i32, success: Ordering, failure: Ordering, ) -> Result<i32, i32>
Stores a value into the atomic if the current value is the same
as the current
value.
See, e.g., atomic::AtomicI32::compare_exchange_weak
.
Sourcepub fn fetch_update<F>(
&self,
set_order: Ordering,
fetch_order: Ordering,
f: F,
) -> Result<i32, i32>
pub fn fetch_update<F>( &self, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<i32, i32>
Fetches the value, and applies a function to it that returns an optional new value.
See, e.g., atomic::AtomicI32::fetch_update
.
Sourcepub const fn as_ptr(&self) -> *mut i32
pub const fn as_ptr(&self) -> *mut i32
Returns a mutable pointer to the underlying value.
See, e.g., atomic::AtomicI32::as_ptr
.
Source§impl AtomicFallback
impl AtomicFallback
Sourcepub fn fetch_add(&self, val: i32, order: Ordering) -> i32
pub fn fetch_add(&self, val: i32, order: Ordering) -> i32
Adds to the current value, returning the previous value.
See, e.g., atomic::AtomicI32::fetch_add
.
Sourcepub fn fetch_sub(&self, val: i32, order: Ordering) -> i32
pub fn fetch_sub(&self, val: i32, order: Ordering) -> i32
Subtracts from the current value, returning the previous value.
See, e.g., atomic::AtomicI32::fetch_sub
.
Sourcepub fn fetch_and(&self, val: i32, order: Ordering) -> i32
pub fn fetch_and(&self, val: i32, order: Ordering) -> i32
Bitwise “and” with the current value.
See, e.g., atomic::AtomicI32::fetch_and
.
Sourcepub fn fetch_nand(&self, val: i32, order: Ordering) -> i32
pub fn fetch_nand(&self, val: i32, order: Ordering) -> i32
Bitwise “nand” with the current value.
See, e.g., atomic::AtomicI32::fetch_nand
.
Sourcepub fn fetch_or(&self, val: i32, order: Ordering) -> i32
pub fn fetch_or(&self, val: i32, order: Ordering) -> i32
Bitwise “or” with the current value.
See, e.g., atomic::AtomicI32::fetch_or
.
Sourcepub fn fetch_xor(&self, val: i32, order: Ordering) -> i32
pub fn fetch_xor(&self, val: i32, order: Ordering) -> i32
Bitwise “xor” with the current value.
See, e.g., atomic::AtomicI32::fetch_xor
.