Skip to main content

AtomicPtr

Struct AtomicPtr 

Source
pub struct AtomicPtr<T>(/* private fields */);
Expand description

Mock implementation of std::sync::atomic::AtomicPtr or portable_atomic::AtomicPtr.

Implementations§

Source§

impl<T> AtomicPtr<T>

Source

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

Creates a new instance of AtomicPtr.

Source

pub fn into_inner(self) -> *mut T

Consumes the atomic and returns the contained value.

Source

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

Loads a value from the pointer.

Source

pub fn store(&self, val: *mut T, order: Ordering)

Stores a value into the pointer.

Source

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

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

Source

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.

Source

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.

Source

pub fn fetch_update<F>( &self, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<*mut T, *mut T>
where F: FnMut(*mut T) -> Option<*mut T>,

Fetches the value, and applies a function to it that returns an optional new value.

Trait Implementations§

Source§

impl<T> Debug for AtomicPtr<T>

Source§

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

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

impl<T> Default for AtomicPtr<T>

Source§

fn default() -> Self

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

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

Source§

fn from(v: *mut 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.