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 awaited. In the same way the read method will return a Future resolving to an AsyncReadLockGuard when awaited.

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

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

impl<T> Unpin for AsyncRWLock<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.