pub struct AtomicConstPtr<T> { /* private fields */ }Expand description
An atomic pointer type which operates on *const T.
This type provides a typed wrapper around [AtomicPtr] that enforces *const T
invariants throughout its API, avoiding the need for cast_mut() or manual
pointer qualification casts at call sites.
Implementations§
Source§impl<T> AtomicConstPtr<T>
impl<T> AtomicConstPtr<T>
Sourcepub fn load(&self, order: Ordering) -> *const T
pub fn load(&self, order: Ordering) -> *const T
Loads a value from the pointer with the specified memory ordering.
Sourcepub fn store(&self, ptr: *const T, order: Ordering)
pub fn store(&self, ptr: *const T, order: Ordering)
Stores a value into the pointer with the specified memory ordering.
Sourcepub fn swap(&self, ptr: *const T, order: Ordering) -> *const T
pub fn swap(&self, ptr: *const T, order: Ordering) -> *const T
Stores a value into the pointer, returning the previous value.
Sourcepub fn compare_exchange(
&self,
current: *const T,
new: *const T,
success: Ordering,
failure: Ordering,
) -> Result<*const T, *const T>
pub fn compare_exchange( &self, current: *const T, new: *const T, success: Ordering, failure: Ordering, ) -> Result<*const T, *const T>
Stores a value into the pointer if the current value is the same as current.
The return value is a result indicating whether the new value was written and containing the previous value.
Sourcepub fn compare_exchange_weak(
&self,
current: *const T,
new: *const T,
success: Ordering,
failure: Ordering,
) -> Result<*const T, *const T>
pub fn compare_exchange_weak( &self, current: *const T, new: *const T, success: Ordering, failure: Ordering, ) -> Result<*const T, *const T>
Stores a value into the pointer if the current value is the same as current.
Unlike [compare_exchange], this function is allowed to spuriously fail.
Sourcepub fn try_update<F>(
&self,
set_order: Ordering,
fetch_order: Ordering,
f: F,
) -> Result<*const T, *const T>where
F: FnMut(*const T) -> Option<*const T>,
pub fn try_update<F>(
&self,
set_order: Ordering,
fetch_order: Ordering,
f: F,
) -> Result<*const T, *const T>where
F: FnMut(*const T) -> Option<*const T>,
Fetches the value, and applies a function to it that returns an optional new value. Returns
a Result of Ok(previous_value) if the function returned Some(_), else
Err(previous_value).
Sourcepub fn into_inner(self) -> *const T
pub fn into_inner(self) -> *const T
Consumes the atomic pointer, returning the underlying raw pointer.