pub struct Atom<P> where
P: IntoRawPtr + FromRawPtr, { /* private fields */ }
Expand description
An Atom wraps an AtomicPtr, it allows for safe mutation of an atomic into common Rust Types.
Implementations
sourceimpl<P> Atom<P> where
P: IntoRawPtr + FromRawPtr,
impl<P> Atom<P> where
P: IntoRawPtr + FromRawPtr,
sourcepub fn swap(&self, v: P) -> Option<P>
pub fn swap(&self, v: P) -> Option<P>
Swap a new value into the Atom, This will try multiple times until it succeeds. The old value will be returned.
sourcepub fn take(&self) -> Option<P>
pub fn take(&self) -> Option<P>
Take the value of the Atom replacing it with null pointer
Returning the contents. If the contents was a null
pointer the
result will be None
.
sourcepub fn set_if_none(&self, v: P) -> Option<P>
pub fn set_if_none(&self, v: P) -> Option<P>
This will do a CAS
setting the value only if it is NULL
this will return None
if the value was written,
otherwise a Some(v)
will be returned, where the value was
the same value that you passed into this function
sourcepub fn replace_and_set_next(&self, value: P) -> bool where
P: GetNextMut<NextPtr = Option<P>>,
pub fn replace_and_set_next(&self, value: P) -> bool where
P: GetNextMut<NextPtr = Option<P>>,
Take the current content, write it into P then do a CAS to extent this Atom with the previous contents. This can be used to create a LIFO
Returns true if this set this migrated the Atom from null.
Trait Implementations
sourceimpl<P> Debug for Atom<P> where
P: IntoRawPtr + FromRawPtr,
impl<P> Debug for Atom<P> where
P: IntoRawPtr + FromRawPtr,
sourceimpl<P> Drop for Atom<P> where
P: IntoRawPtr + FromRawPtr,
impl<P> Drop for Atom<P> where
P: IntoRawPtr + FromRawPtr,
impl<P> Send for Atom<P> where
P: IntoRawPtr + FromRawPtr + Send,
impl<P> Sync for Atom<P> where
P: IntoRawPtr + FromRawPtr + Send,
Auto Trait Implementations
impl<P> RefUnwindSafe for Atom<P> where
P: RefUnwindSafe,
impl<P> Unpin for Atom<P> where
P: Unpin,
impl<P> UnwindSafe for Atom<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more