Struct radium::types::Radon

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

Non-Atomic Primitives

This family takes a Rust primitive (bool, integer, or pointer) as a type parameter and wraps it in a Cell. Like Atom<T> and Isotope<T>, it implements only the Radium API (and Debug, Default, and From<T>), and as such is suitable for cases where a crate wants to turn off atomic usage entirely, while guaranteeing that swapping out types will not cause a compilation failure.

Examples

Consider a crate with an "atomic" feature. It might decide to attempt atomic behavior when this flag is on, and unconditionally deny it when the flag is off:

#[cfg(feature = "atomic")]
pub type MyAtom<T> = radium::types::Isotope<T>;

#[cfg(not(feature = "atomic"))]
pub type MyAtom<T> = radium::types::Radon<T>;

Behind the Name

Radium decays into radon, and the Radon type is a “decayed” Radium implementor. Radon gas is also poisonous, and Radon poisons your codebase against multithreading.

Trait Implementations§

source§

impl<T> Debug for Radon<T>
where T: Nuclear + Debug, Cell<T>: 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 Radon<T>
where T: Nuclear + Default, Cell<T>: Radium<Item = T> + Default,

source§

fn default() -> Self

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

impl<T> From<T> for Radon<T>
where T: Nuclear, Cell<T>: Radium<Item = T> + From<T>,

source§

fn from(val: T) -> Self

Converts to this type from the input type.
source§

impl<T> Radium for Radon<T>
where T: Nuclear + PartialEq, Cell<T>: 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(_: 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 Radon<T>

§

impl<T> Send for Radon<T>
where T: Send,

§

impl<T> !Sync for Radon<T>

§

impl<T> Unpin for Radon<T>
where T: Unpin,

§

impl<T> UnwindSafe for Radon<T>
where T: 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<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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.