Struct ruspiro_lock::async::AsyncMutex [−][src]
pub struct AsyncMutex<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 MutexGuard immediately but a
Future that will resove into a AsyncMutexGuard when await
ed.
Implementations
impl<T> AsyncMutex<T>
[src]
pub fn new(value: T) -> Self
[src]
Create the AsyncMutex
pub async fn lock(&self) -> AsyncMutexGuard<'_, T>
[src]
Locking the data secured by the AsyncMutex 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 AsyncMutex. 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 AsyncMutex
in the Err
variant.
Auto Trait Implementations
impl<T> Send for AsyncMutex<T> where
T: Send,
T: Send,
impl<T> Sync for AsyncMutex<T> where
T: Send,
T: Send,
impl<T> Unpin for AsyncMutex<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>,