pub struct RwLock<T> { /* private fields */ }Expand description
Reader-writer lock owning a T. See module docs for semantics.
Implementations§
Source§impl<T> RwLock<T>
impl<T> RwLock<T>
Sourcepub const fn new(value: T) -> Self
pub const fn new(value: T) -> Self
Const-init. Parity with parking_lot::RwLock::new /
parking_lot::const_rwlock.
Sourcepub fn read(&self) -> RwLockReadGuard<'_, T>
pub fn read(&self) -> RwLockReadGuard<'_, T>
Acquire a shared read lock, blocking if a writer holds (or is waiting for) the lock.
Sourcepub fn write(&self) -> RwLockWriteGuard<'_, T>
pub fn write(&self) -> RwLockWriteGuard<'_, T>
Acquire an exclusive write lock, blocking until all readers and any other writer have released.
Sourcepub fn try_read(&self) -> Option<RwLockReadGuard<'_, T>>
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, T>>
Non-blocking read.
Sourcepub fn try_write(&self) -> Option<RwLockWriteGuard<'_, T>>
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, T>>
Non-blocking write.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Lock-free mutable access via &mut self (exclusive borrow proves no
other thread holds the lock). Parity with parking_lot::RwLock::get_mut.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the lock, returning the inner value.
Trait Implementations§
impl<T: Send> Send for RwLock<T>
impl<T: Send + Sync> Sync for RwLock<T>
Auto Trait Implementations§
impl<T> !Freeze for RwLock<T>
impl<T> !RefUnwindSafe for RwLock<T>
impl<T> Unpin for RwLock<T>where
UnsafeCell<T>: Unpin,
impl<T> UnsafeUnpin for RwLock<T>where
UnsafeCell<T>: UnsafeUnpin,
impl<T> UnwindSafe for RwLock<T>where
UnsafeCell<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.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