AsyncLockable

Trait AsyncLockable 

Source
pub trait AsyncLockable {
    type GuardMut<'a>: AsyncGuardMut<'a, Locker = Self> + Send + Unpin
       where Self: 'a;
    type GuardMutFuture<'a>: Future<Output = Self::GuardMut<'a>> + Send
       where Self: 'a;

    // Required methods
    fn lock(&self) -> Self::GuardMutFuture<'_>;
    fn unlock<'a>(guard: Self::GuardMut<'a>) -> &'a Self;
}
Expand description

A futures-aware lockable mutex object should implement this trait.

Required Associated Types§

Source

type GuardMut<'a>: AsyncGuardMut<'a, Locker = Self> + Send + Unpin where Self: 'a

RAII scoped lock guard type.

A guard of futures-aware mutex must be able to transfer between threads In other words, this guard must not track any thread-specific details

Source

type GuardMutFuture<'a>: Future<Output = Self::GuardMut<'a>> + Send where Self: 'a

Future created by lock function

Required Methods§

Source

fn lock(&self) -> Self::GuardMutFuture<'_>

Acquire the lock asynchronously.

Source

fn unlock<'a>(guard: Self::GuardMut<'a>) -> &'a Self

Immediately drops the guard, and consequently unlocks the Lockable object.

The return value is the associated Lockable object of this guard

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Locker, Wakers, Mediator> AsyncLockable for AsyncLockableMaker<Locker, Wakers>
where Locker: Lockable + Send + Sync, for<'a> Locker::GuardMut<'a>: Send + Unpin, Wakers: Lockable + Send + Sync, for<'b> Wakers::GuardMut<'b>: DerefMut<Target = Mediator>, Mediator: AsyncLockableMediator + 'static,

Source§

type GuardMut<'a> = AsyncLockableMakerGuard<'a, Locker, Wakers, Mediator> where Self: 'a

Source§

type GuardMutFuture<'a> = AsyncLockableMakerFuture<'a, Locker, Wakers, Mediator> where Self: 'a