pub struct AtomicPtr<T>(_);
Expand description
Mock implementation of std::sync::atomic::AtomicPtr
.
NOTE: Unlike std::sync::atomic::AtomicPtr
, this type has a different
in-memory representation than *mut T
.
Implementations
sourceimpl<T> AtomicPtr<T>
impl<T> AtomicPtr<T>
sourcepub unsafe fn unsync_load(&self) -> *mut T
pub unsafe fn unsync_load(&self) -> *mut T
Load the value without any synchronization.
Safety
An unsynchronized atomic load technically always has undefined behavior.
However, if the atomic value is not currently visible by other threads,
this should always be equivalent to a non-atomic load of an un-shared
*mut T
value.
sourcepub fn with_mut<R>(&mut self, f: impl FnOnce(&mut *mut T) -> R) -> R
pub fn with_mut<R>(&mut self, f: impl FnOnce(&mut *mut T) -> R) -> R
Get access to a mutable reference to the inner value.
sourcepub fn swap(&self, val: *mut T, order: Ordering) -> *mut T
pub fn swap(&self, val: *mut T, order: Ordering) -> *mut T
Stores a value into the pointer, returning the previous value.
sourcepub fn compare_and_swap(
&self,
current: *mut T,
new: *mut T,
order: Ordering
) -> *mut T
pub fn compare_and_swap(
&self,
current: *mut T,
new: *mut T,
order: Ordering
) -> *mut T
Stores a value into the pointer if the current value is the same as the current
value.
sourcepub fn compare_exchange(
&self,
current: *mut T,
new: *mut T,
success: Ordering,
failure: Ordering
) -> Result<*mut T, *mut T>
pub fn compare_exchange(
&self,
current: *mut T,
new: *mut T,
success: Ordering,
failure: Ordering
) -> Result<*mut T, *mut T>
Stores a value into the pointer if the current value is the same as the current
value.
sourcepub fn compare_exchange_weak(
&self,
current: *mut T,
new: *mut T,
success: Ordering,
failure: Ordering
) -> Result<*mut T, *mut T>
pub fn compare_exchange_weak(
&self,
current: *mut T,
new: *mut T,
success: Ordering,
failure: Ordering
) -> Result<*mut T, *mut T>
Stores a value into the atomic if the current value is the same as the current value.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for AtomicPtr<T>
impl<T> Send for AtomicPtr<T>
impl<T> Sync for AtomicPtr<T>
impl<T> Unpin for AtomicPtr<T>
impl<T> UnwindSafe for AtomicPtr<T>
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more