Crate futures_locks

Crate futures_locks 

Source
Expand description

A library of Futures-aware locking primitives. These locks can safely be used in asynchronous environments like Tokio. When they block, they’ll only block a single task, not the entire reactor.

These primitives generally work much like their counterparts from the standard library. But instead of blocking, they return a Future that completes when the lock has been acquired.

§Examples

let mtx = Mutex::<u32>::new(0);
let fut = mtx.lock().map(|mut guard| { *guard += 5; });
block_on(fut);
assert_eq!(mtx.try_unwrap().unwrap(), 5);

Structs§

Mutex
A Futures-aware Mutex.
MutexFut
A Future representing a pending Mutex acquisition.
MutexGuard
An RAII mutex guard, much like std::sync::MutexGuard. The wrapped data can be accessed via its Deref and DerefMut implementations.
MutexWeak
MutexWeak is a non-owning reference to a Mutex. MutexWeak is to Mutex as std::sync::Weak is to std::sync::Arc.
RwLock
A Futures-aware RwLock.
RwLockReadFut
A Future representing a pending RwLock shared acquisition.
RwLockReadGuard
An RAII guard, much like std::sync::RwLockReadGuard. The wrapped data can be accessed via its Deref implementation.
RwLockWriteFut
A Future representing a pending RwLock exclusive acquisition.
RwLockWriteGuard
An RAII guard, much like std::sync::RwLockWriteGuard. The wrapped data can be accessed via its Deref and DerefMut implementations.
TryLockError
The lock could not be acquired at this time because the operation would otherwise block.