[][src]Struct crndm::prc::Weak

pub struct Weak<T: PSafe + ?Sized, A: MemPool> { /* fields omitted */ }

Weak is a version of Prc that holds a non-owning reference to the managed allocation. The allocation is accessed by calling upgrade on the Weak pointer, which returns an Option<Prc<T>>.

Since a Weak reference does not count towards ownership, it will not prevent the value stored in the allocation from being dropped, and Weak itself makes no guarantees about the value still being present. Thus it may return None when upgraded. Note however that a Weak reference does prevent the allocation itself (the backing store) from being deallocated.

A Weak pointer is useful for keeping a temporary reference to the allocation managed by Prc without preventing its inner value from being dropped. It is also used to prevent circular references between Prc pointers, since mutual owning references would never allow either Prc to be dropped. For example, a tree could have strong Prc pointers from parent nodes to children, and Weak pointers from children back to their parents.

The typical way to obtain a Weak pointer is to call Prc::downgrade.

Implementations

impl<T: PSafe, A: MemPool> Weak<T, A>[src]

pub fn as_raw(&self) -> *const T[src]

pub fn into_raw(self) -> *const T[src]

pub unsafe fn from_raw(ptr: *const T) -> Self[src]

impl<T: PSafe + ?Sized, A: MemPool> Weak<T, A>[src]

pub fn new() -> Weak<T, A>[src]

Creates a new dangling weak pointer

pub fn upgrade(&self, journal: &Journal<A>) -> Option<Prc<T, A>>[src]

pub fn strong_count(&self) -> usize[src]

pub fn weak_count(&self) -> Option<usize>[src]

pub fn ptr_eq(&self, other: &Self) -> bool[src]

Trait Implementations

impl<T: PSafe + Debug + ?Sized, A: MemPool> Debug for Weak<T, A>[src]

impl<T: PSafe + ?Sized, A: MemPool> Drop for Weak<T, A>[src]

impl<T: PSafe + ?Sized, A: MemPool> PClone<A> for Weak<T, A>[src]

impl<T: PSafe + ?Sized, A: MemPool> RootObj<A> for Weak<T, A>[src]

impl<T: ?Sized, A: MemPool> !Send for Weak<T, A>[src]

impl<T: ?Sized, A: MemPool> !Sync for Weak<T, A>[src]

impl<T: ?Sized, A: MemPool> !TxOutSafe for Weak<T, A>[src]

impl<T: ?Sized, A: MemPool> !VSafe for Weak<T, A>[src]

Auto Trait Implementations

impl<T: ?Sized, A> LooseTxInUnsafe for Weak<T, A> where
    A: LooseTxInUnsafe,
    T: LooseTxInUnsafe
[src]

impl<T: ?Sized, A> PSafe for Weak<T, A>[src]

impl<T: ?Sized, A> RefUnwindSafe for Weak<T, A> where
    A: RefUnwindSafe
[src]

impl<T: ?Sized, A> TxInSafe for Weak<T, A> where
    A: TxInSafe
[src]

impl<T: ?Sized, A> Unpin for Weak<T, A> where
    A: Unpin,
    T: Unpin
[src]

impl<T: ?Sized, A> UnwindSafe for Weak<T, A> where
    A: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,