Skip to main content

RcuWeak

Struct RcuWeak 

Source
pub struct RcuWeak<T: Send + Sync + 'static> { /* private fields */ }
Expand description

An RCU (Read-Copy-Update) wrapper around a Weak pointer.

The weak pointer can be read and upgraded from multiple threads concurrently without blocking. When the weak pointer is replaced, reads may continue to see the old weak pointer for some period of time.

Implementations§

Source§

impl<T: Send + Sync + 'static> RcuWeak<T>

Source

pub fn new(data: Weak<T>) -> Self

Create a new RCU wrapper around a Weak pointer.

Source

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

Try to upgrade the wrapped Weak pointer to an Arc.

Returns None if the weak pointer has expired and the referenced object was destroyed or if the RcuWeak is in a transient state during drop.

Source

pub fn to_weak(&self) -> Weak<T>

Create a new Weak pointer to the object referenced by the wrapped Weak pointer.

Source

pub fn ptr_eq(&self, other: &Weak<T>) -> bool

Check if the wrapped weak pointer points to the same allocation as other.

Source

pub fn update(&self, data: Weak<T>)

Write a new Weak pointer to the RCU wrapper.

Concurrent readers may continue to see the old weak pointer until the RCU state machine has made sufficient progress to ensure that no concurrent readers are holding read guards.

Trait Implementations§

Source§

impl<T: Send + Sync + 'static> Clone for RcuWeak<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Send + Sync + 'static> Debug for RcuWeak<T>

Source§

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

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

impl<T: Send + Sync + 'static> Default for RcuWeak<T>

Source§

fn default() -> Self

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

impl<T: Send + Sync + 'static> Drop for RcuWeak<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: Send + Sync + 'static> From<Weak<T>> for RcuWeak<T>

Source§

fn from(weak: Weak<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !Freeze for RcuWeak<T>

§

impl<T> RefUnwindSafe for RcuWeak<T>

§

impl<T> Send for RcuWeak<T>

§

impl<T> Sync for RcuWeak<T>

§

impl<T> Unpin for RcuWeak<T>

§

impl<T> UnsafeUnpin for RcuWeak<T>

§

impl<T> UnwindSafe for RcuWeak<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.