Struct AtomicFallback

Source
pub struct AtomicFallback { /* private fields */ }
Available on 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

Source

pub const fn new(v: i32) -> Self

Creates a new atomic.

See, e.g., atomic::AtomicI32::new.

Source

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

Returns a mutable reference to the underlying value.

See, e.g., atomic::AtomicI32::get_mut.

Source

pub fn into_inner(self) -> i32

Consumes the atomic and returns the contained value.

See, e.g., atomic::AtomicI32::into_inner.

Source

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

Loads a value from the atomic.

See, e.g., atomic::AtomicI32::load.

Source

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

Stores a value into the atomic.

See, e.g., atomic::AtomicI32::store.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn fetch_update<F>( &self, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<i32, i32>
where F: FnMut(i32) -> Option<i32>,

Fetches the value, and applies a function to it that returns an optional new value.

See, e.g., atomic::AtomicI32::fetch_update.

Source

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

Source

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.

Source

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.

Source

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

Bitwise “and” with the current value.

See, e.g., atomic::AtomicI32::fetch_and.

Source

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

Bitwise “nand” with the current value.

See, e.g., atomic::AtomicI32::fetch_nand.

Source

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

Bitwise “or” with the current value.

See, e.g., atomic::AtomicI32::fetch_or.

Source

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

Bitwise “xor” with the current value.

See, e.g., atomic::AtomicI32::fetch_xor.

Source

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

Maximum with the current value.

See, e.g., atomic::AtomicI32::fetch_max.

Source

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

Minimum with the current value.

See, e.g., atomic::AtomicI32::fetch_min.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.