pub struct Isotope<T>{ /* private fields */ }
Expand description
Best-Effort Atomic Primitives
This family takes a Rust primitive (bool
, integer, or pointer) as a type
parameter and acts as the corresponding RadiumT
type. Unlike the Atom<T>
sibling type, this type will never produce a compiler error when instantiated
(with a valid primitive). When the requisite atomic support is missing on the
target architecture, it falls back to acting as a Cell<T>
.
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, and in particular does not attempt to follow the Cell
API.
See also Radon<T>
, which is always strictly non-atomic.
Trait Implementations§
source§impl<T> Radium for Isotope<T>
impl<T> Radium for Isotope<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(order: Ordering)
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 Isotope<T>
impl<T> Send for Isotope<T>
impl<T> Sync for Isotope<T>
impl<T> Unpin for Isotope<T>
impl<T> UnwindSafe for Isotope<T>
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