pub struct Radon<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> Radium for Radon<T>
impl<T> Radium for Radon<T>
source§fn get_mut(&mut self) -> &mut T
fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying value. Read more
source§fn into_inner(self) -> T
fn into_inner(self) -> T
Consumes the wrapper and returns the contained value. Read more
source§fn swap(&self, value: T, order: Ordering) -> T
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
fn compare_and_swap(&self, current: T, new: T, order: Ordering) -> T
👎Deprecated: Use
compare_exchange
or compare_exchange_weak
insteadStores a new value into this object if (and only if) the value currently
stored in it is the same as the
current
argument. Read moresource§fn compare_exchange(
&self,
current: T,
new: T,
success: Ordering,
failure: Ordering
) -> Result<T, T>
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 moresource§fn compare_exchange_weak(
&self,
current: T,
new: T,
success: Ordering,
failure: Ordering
) -> Result<T, T>
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 moresource§fn fetch_and(&self, value: T, order: Ordering) -> Twhere
T: BitOps,
fn fetch_and(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: BitOps,
fn fetch_nand(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: BitOps,
fn fetch_or(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: BitOps,
fn fetch_xor(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: NumericOps,
fn fetch_add(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: NumericOps,
fn fetch_sub(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: NumericOps,
fn fetch_max(&self, value: T, order: Ordering) -> Twhere
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) -> Twhere
T: NumericOps,
fn fetch_min(&self, value: T, order: Ordering) -> Twhere
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>
fn fetch_update<F>( &self, set_order: Ordering, fetch_order: Ordering, func: F ) -> Result<T, T>
Fetches the value, and applies a function to it that may produce a new
value. Read more
source§fn fence(_: Ordering)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more