Struct radium::types::Atom

source ·
pub struct Atom<T>
where T: Atomic, T::Atom: Radium<Item = T>,
{ /* private fields */ }
Expand description

Atomic Primitives

This family takes a Rust primitive (bool, integer, or pointer) as a type parameter and acts as the corresponding AtomicT type. Attempting to construct an Atom<T> on a target that has no AtomicT will cause a compilation failure stating that T does not implement the Atomic trait. The Isotope<T> sibling type will never fail to compile, but in exchange does not guarantee atomic behavior.

This type implements the Radium API, as well as the Debug, Default, and From<T> traits that the standard library atomics implement. It has no other API surface.

Trait Implementations§

source§

impl<T> Debug for Atom<T>
where T: Atomic + Debug, T::Atom: Radium<Item = T> + Debug,

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for Atom<T>
where T: Atomic + Default, T::Atom: Radium<Item = T> + Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> From<T> for Atom<T>
where T: Atomic, T::Atom: Radium<Item = T> + From<T>,

source§

fn from(val: T) -> Self

Converts to this type from the input type.
source§

impl<T> Radium for Atom<T>
where T: Atomic + PartialEq, T::Atom: Radium<Item = T>,

§

type Item = T

The primitive type that this implementor makes shared-mutable.
source§

fn new(value: T) -> Self

Creates a new value of this type.
source§

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

Returns a mutable reference to the underlying value. Read more
source§

fn into_inner(self) -> T

Consumes the wrapper and returns the contained value. Read more
source§

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

Loads a value from this object. Read more
source§

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

Stores a value into this object. Read more
source§

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

Swaps a new value with the value stored in this object. Read more
source§

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

👎Deprecated: Use compare_exchange or compare_exchange_weak instead
Stores a new value into this object if (and only if) the value currently stored in it is the same as the current argument. Read more
source§

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

Stores a new value into this object if (and only if) the value currently stored in it is the same as the current argument. Read more
source§

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

Stores a new value into this object if (and only if) the value currently stored in it is the same as the current argument. Read more
source§

fn fetch_and(&self, value: T, order: Ordering) -> T
where T: BitOps,

Performs a bit-wise AND on the currently-stored value and the argument. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_nand(&self, value: T, order: Ordering) -> T
where T: BitOps,

Performs a bit-wise NAND on the currently-stored value and the argument. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_or(&self, value: T, order: Ordering) -> T
where T: BitOps,

Performs a bit-wise OR on the currently-stored value and the argument. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_xor(&self, value: T, order: Ordering) -> T
where T: BitOps,

Performs a bit-wise XOR on the currently-stored value and the argument. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_add(&self, value: T, order: Ordering) -> T
where T: NumericOps,

Adds the argument into the currently-stored value, wrapping on overflow. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_sub(&self, value: T, order: Ordering) -> T
where T: NumericOps,

Subtracts the argument from the currently-stored value, wrapping on overflow. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_max(&self, value: T, order: Ordering) -> T
where T: NumericOps,

Finds the maximum of the currently-stored value and the argument. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_min(&self, value: T, order: Ordering) -> T
where T: NumericOps,

Finds the minimum of the currently-stored value and the argument. The result is stored into this object, and the previous value is returned. Read more
source§

fn fetch_update<F>( &self, set_order: Ordering, fetch_order: Ordering, func: F ) -> Result<T, T>
where F: FnMut(T) -> Option<T>,

Fetches the value, and applies a function to it that may produce a new value. Read more
source§

fn fence(order: Ordering)

If the implementor is atomic, this calls atomic::fence with the given Ordering; otherwise, it does nothing.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Atom<T>
where <T as Atomic>::Atom: RefUnwindSafe,

§

impl<T> Send for Atom<T>

§

impl<T> Sync for Atom<T>

§

impl<T> Unpin for Atom<T>
where <T as Atomic>::Atom: Unpin,

§

impl<T> UnwindSafe for Atom<T>
where <T as Atomic>::Atom: UnwindSafe,

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>,

§

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>,

§

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.