pub struct TRefLock<T: ?Sized> { /* private fields */ }Expand description
J-C cfg-gated interior-mutable lock. Exposes RefCell-shaped
.borrow() / .borrow_mut() whose returned guards Deref<Target = T>. Under the default feature set this is a thin newtype around
RefCell<T> (zero overhead vs. the pre-J-C RefCell field);
under feature = "send" it wraps RwLock<T> and the guards
become RwLockReadGuard / RwLockWriteGuard.
Lock failure handling: the send build unwrap()s the lock result.
The SendVm’s outer RwLock<()> serializes mutator access so a
poisoned lock is a real bug (a panic in a guard’s user) and the
propagating panic is the same UX as RefCell::borrow_mut on a
re-entrant borrow.
Implementations§
Source§impl<T> TRefLock<T>
impl<T> TRefLock<T>
Sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Borrow the lock immutably. The returned guard derefs to &T;
callers use it identically to RefCell::borrow.
Sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Borrow the lock mutably. The returned guard derefs to &mut T;
callers use it identically to RefCell::borrow_mut.