pub struct RwLock<T> { /* private fields */ }
Expand description
Mock implementation of std::sync::RwLock
Implementations
sourceimpl<T> RwLock<T>
impl<T> RwLock<T>
sourcepub fn read(&self) -> LockResult<RwLockReadGuard<'_, T>>
pub fn read(&self) -> LockResult<RwLockReadGuard<'_, T>>
Locks this rwlock with shared read access, blocking the current thread until it can be acquired.
The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns. This method does not provide any guarantees with respect to the ordering of whether contentious readers or writers will acquire the lock first.
sourcepub fn try_read(&self) -> TryLockResult<RwLockReadGuard<'_, T>>
pub fn try_read(&self) -> TryLockResult<RwLockReadGuard<'_, T>>
Attempts to acquire this rwlock with shared read access.
If the access could not be granted at this time, then Err is returned. Otherwise, an RAII guard is returned which will release the shared access when it is dropped.
This function does not block.
sourcepub fn write(&self) -> LockResult<RwLockWriteGuard<'_, T>>
pub fn write(&self) -> LockResult<RwLockWriteGuard<'_, T>>
Locks this rwlock with exclusive write access, blocking the current thread until it can be acquired.
This function will not return while other writers or other readers currently have access to the lock.
sourcepub fn try_write(&self) -> TryLockResult<RwLockWriteGuard<'_, T>>
pub fn try_write(&self) -> TryLockResult<RwLockWriteGuard<'_, T>>
Attempts to lock this rwlock with exclusive write access.
If the lock could not be acquired at this time, then Err is returned. Otherwise, an RAII guard is returned which will release the lock when it is dropped.
This function does not block.
sourcepub fn into_inner(self) -> LockResult<T>
pub fn into_inner(self) -> LockResult<T>
Consumes this RwLock
, returning the underlying data.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for RwLock<T>
impl<T> Send for RwLock<T> where
T: Send,
impl<T> Sync for RwLock<T> where
T: Send + Sync,
impl<T> Unpin for RwLock<T> where
T: Unpin,
impl<T> UnwindSafe for RwLock<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more