pub struct LockWeak<T> { /* private fields */ }
Expand description
Weak reference to a ParentArc
.
This instance can be locked at any moment, you can try to upgrade it into a
ChildArc
which assures it can be read until the reader is dropped.
The typical way to obtain a Weak pointer is to call
ParentArc::downgrade
.
Implementations§
Source§impl<T> LockWeak<T>
impl<T> LockWeak<T>
Sourcepub fn upgrade(&self) -> Option<ChildArc<T>>
pub fn upgrade(&self) -> Option<ChildArc<T>>
Upgrades this Weak reference into a ChildArc
if the data is
unlocked or still owned by the ParentArc
.
§Examples
use parc::{ParentArc, LockWeak};
use std::sync::Mutex;
fn main() {
let parent = ParentArc::new(Mutex::new(true));
let weak: LockWeak<_> = ParentArc::downgrade(&parent);
let child = weak.upgrade().unwrap();
}
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for LockWeak<T>
impl<T> RefUnwindSafe for LockWeak<T>where
T: RefUnwindSafe,
impl<T> !Sync for LockWeak<T>
impl<T> Unpin for LockWeak<T>
impl<T> UnwindSafe for LockWeak<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more