AtomicArc

Struct AtomicArc 

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

A reference-counted, nullable, atomic pointer.

Implementations§

Source§

impl<T> AtomicArc<T>

Source

pub fn new(data: Option<T>) -> AtomicArc<T>

Create a new AtomicArc.

Source

pub fn from_arc(arc: Option<Arc<T>>) -> AtomicArc<T>

Create a new AtomicArc from an Arc.

Source

pub fn get_arc(&mut self) -> Option<Arc<T>>

Get the value of the pointer as an Arc. This can be done non-atomically since we have a unique reference to the AtomicArc.

Source

pub fn get(&mut self) -> Option<&T>

Get a reference to the value stored in this AtomicArc. This can be done non-atomically since we have a unique reference to the AtomicArc.

Source

pub fn into_arc(self) -> Option<Arc<T>>

Convert this AtomicArc into a plain old Arc

Source

pub fn load(&self, order: Ordering) -> Option<Arc<T>>

Load the value stored in this AtomicArc

Source

pub fn store(&self, new: Option<Arc<T>>, order: Ordering)

Store a new value.

Source

pub fn swap(&self, new: Option<Arc<T>>, order: Ordering) -> Option<Arc<T>>

Atomically swap the value stored in this AtomicArc with the new value, returning the old value.

Source

pub fn compare_and_swap( &self, old: Option<Arc<T>>, new: Option<Arc<T>>, order: Ordering, ) -> Option<Arc<T>>

Atomically swaps the value stored in this AtomicArc if old points to the same Arc as what is currently stored. This does not compare the underlying data, merely that the pointers match. Returns the previous value stored in this AtomicArc, which will be the same as old if the swap was successful.

Auto Trait Implementations§

§

impl<T> !Freeze for AtomicArc<T>

§

impl<T> RefUnwindSafe for AtomicArc<T>

§

impl<T> Send for AtomicArc<T>

§

impl<T> Sync for AtomicArc<T>

§

impl<T> Unpin for AtomicArc<T>

§

impl<T> UnwindSafe for AtomicArc<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.