Struct ruspiro_lock::async::AsyncRWLock [−][src]
pub struct AsyncRWLock<T> { /* fields omitted */ }
An async mutex lock that can be used in async functions to prevent blocking current execution while waiting for the
lock to become available. So for this to work the lock
method does not return a WriteGuard immediately but a
Future that will resolve into a AsyncWriteLockGuard when await
ed.
In the same way the read
method will return a Future
resolving to an AsyncReadLockGuard when await
ed.
Implementations
impl<T> AsyncRWLock<T>
[src]
pub fn new(value: T) -> Self
[src]
Create the AsyncRWLock
pub async fn lock(&self) -> AsyncWriteLockGuard<'_, T>
[src]
Locking the data for write access secured by the AsyncRWLock will yield a Future
that must be awaited to
actually acquire the lock.
pub async fn read(&self) -> AsyncReadLockGuard<'_, T>
[src]
Locking the data for read access secured by the AsyncRWLock will yield a Future
that must be awaited to
actually acquire the lock.
pub fn into_inner(self) -> Result<T, Self>
[src]
Provide the inner data wrapped by this AsyncRWLock. This will only provide the contained data if there is only
one active reference to it. If the data is still shared more than once, eg. because there are active Future
s
awaiting a lock this will return the actual AsyncRWLock
in the Err
variant.
Auto Trait Implementations
impl<T> Send for AsyncRWLock<T> where
T: Send,
T: Send,
impl<T> Sync for AsyncRWLock<T> where
T: Send,
T: Send,
impl<T> Unpin for AsyncRWLock<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,