Skip to main content

AtomicPtr

Struct AtomicPtr 

Source
pub struct AtomicPtr<T> { /* private fields */ }
Expand description

A managed atomic pointer type for use with hazard pointer domains.

Wraps AtomicPtr and returns Replaced<T> from mutation operations, ensuring displaced pointers are properly retired.

Implementations§

Source§

impl<T> AtomicPtr<T>

Source

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

Creates a new AtomicPtr from a raw pointer.

Source

pub fn from_box(val: Box<T>) -> Self

Creates a new AtomicPtr from a Box.

Source

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

Atomically loads the raw pointer.

Source

pub fn swap(&self, new: *mut T, order: Ordering) -> Replaced<T>

Atomically swaps the pointer, returning the old value as a Replaced<T> that must be retired.

Source

pub fn compare_exchange( &self, current: *mut T, new: *mut T, success: Ordering, failure: Ordering, ) -> Result<Replaced<T>, *mut T>

Atomically compares and exchanges the pointer. On success, returns Ok(Replaced<T>) containing the old value that must be retired. On failure, returns Err(*mut T) with the current value.

Trait Implementations§

Source§

impl<T: Debug> Debug for AtomicPtr<T>

Source§

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

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

impl<T> From<Atomic<*mut T>> for AtomicPtr<T>

Source§

fn from(ptr: StdAtomicPtr<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Box<T>> for AtomicPtr<T>

Source§

fn from(val: Box<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !Freeze for AtomicPtr<T>

§

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> UnsafeUnpin for AtomicPtr<T>

§

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

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.