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 awaited.

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 Futures 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

impl<T> Sync for AsyncMutex<T> where
    T: Send

impl<T> Unpin for AsyncMutex<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.