Skip to main content

AtomicConstPtr

Struct AtomicConstPtr 

Source
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>

Source

pub const fn new(ptr: *const T) -> Self

Creates a new AtomicConstPtr initialized with ptr.

Source

pub fn load(&self, order: Ordering) -> *const T

Loads a value from the pointer with the specified memory ordering.

Source

pub fn store(&self, ptr: *const T, order: Ordering)

Stores a value into the pointer with the specified memory ordering.

Source

pub fn swap(&self, ptr: *const T, order: Ordering) -> *const T

Stores a value into the pointer, returning the previous value.

Source

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.

Source

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.

Source

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).

Source

pub fn into_inner(self) -> *const T

Consumes the atomic pointer, returning the underlying raw pointer.

Trait Implementations§

Source§

impl<T> Debug for AtomicConstPtr<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for AtomicConstPtr<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> From<*const T> for AtomicConstPtr<T>

Source§

fn from(ptr: *const T) -> Self

Converts to this type from the input type.
Source§

impl<T> Pointer for AtomicConstPtr<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for AtomicConstPtr<T>

§

impl<T> RefUnwindSafe for AtomicConstPtr<T>

§

impl<T> Send for AtomicConstPtr<T>

§

impl<T> Sync for AtomicConstPtr<T>

§

impl<T> Unpin for AtomicConstPtr<T>

§

impl<T> UnsafeUnpin for AtomicConstPtr<T>

§

impl<T> UnwindSafe for AtomicConstPtr<T>
where T: RefUnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.