Struct xarc::AtomicXarc [−][src]
pub struct AtomicXarc<T: Send> { /* fields omitted */ }
Expand description
AtomicXarc
provides atomic storage for Xarc
atomically refcounted smart pointers.
Examples
Here is some typical usage of AtomicXarc
.
use core::sync::atomic::Ordering; use xarc::{AtomicXarc, Xarc}; let atomic = AtomicXarc::new(42); let same = atomic.load(Ordering::Acquire); let different = Xarc::new(42); assert_eq!(*atomic.load(Ordering::Acquire).maybe_deref().unwrap(), 42); assert!(atomic.compare_exchange(&different, &Xarc::null(), Ordering::AcqRel, Ordering::Acquire) .is_err()); assert_eq!(*atomic.compare_exchange(&same, &Xarc::null(), Ordering::AcqRel, Ordering::Acquire) .unwrap().maybe_deref().unwrap(), 42);
Implementations
impl<T: Send> AtomicXarc<T>
[src]
impl<T: Send> AtomicXarc<T>
[src]#[must_use]pub fn compare_and_swap(
&self,
current: &Xarc<T>,
new: &Xarc<T>,
success: Ordering,
failure: Ordering
) -> Xarc<T>
[src]
#[must_use]pub fn compare_and_swap(
&self,
current: &Xarc<T>,
new: &Xarc<T>,
success: Ordering,
failure: Ordering
) -> Xarc<T>
[src]As an atomic operation, swap the contents of self
with new
if self == current
.
Returns the previous value of self
.
If the value does not equal current
the operation failed.
pub fn compare_exchange(
&self,
current: &Xarc<T>,
new: &Xarc<T>,
success: Ordering,
failure: Ordering
) -> Result<Xarc<T>, Xarc<T>>
[src]
pub fn compare_exchange(
&self,
current: &Xarc<T>,
new: &Xarc<T>,
success: Ordering,
failure: Ordering
) -> Result<Xarc<T>, Xarc<T>>
[src]As an atomic operation, swap the contents of self
with new
if self == current
.
Returns the previous value of self
in a Result indicating whether the operation succeeded or failed.
pub fn compare_exchange_weak(
&self,
current: &Xarc<T>,
new: &Xarc<T>,
success: Ordering,
failure: Ordering
) -> Result<Xarc<T>, Xarc<T>>
[src]
pub fn compare_exchange_weak(
&self,
current: &Xarc<T>,
new: &Xarc<T>,
success: Ordering,
failure: Ordering
) -> Result<Xarc<T>, Xarc<T>>
[src]As an atomic operation, swap the contents of self
with new
if self == current
but with spurious failure of the comparison allowed.
Returns the previous value of self
in a Result indicating whether the operation succeeded or failed.
Allowing spurious failure is a performance optimization that is reasonable when no additional loops are required for correctness.
#[must_use]pub fn load(&self, order: Ordering) -> Xarc<T>
[src]
#[must_use]pub fn load(&self, order: Ordering) -> Xarc<T>
[src]Load the value into an Xarc
.
The internal atomic operation is repeated as needed until successful.
Trait Implementations
impl<T: Debug + Send> Debug for AtomicXarc<T>
[src]
impl<T: Debug + Send> Debug for AtomicXarc<T>
[src]impl<T: Send> Drop for AtomicXarc<T>
[src]
impl<T: Send> Drop for AtomicXarc<T>
[src]Auto Trait Implementations
impl<T> RefUnwindSafe for AtomicXarc<T>
impl<T> Send for AtomicXarc<T>
impl<T> Sync for AtomicXarc<T>
impl<T> Unpin for AtomicXarc<T>
impl<T> UnwindSafe for AtomicXarc<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,