async-mutex 1.4.0

Async mutex
Documentation

An async mutex.

The locking mechanism uses eventual fairness to ensure locking will be fair on average without sacrificing performance. This is done by forcing a fair lock whenever a lock operation is starved for longer than 0.5 milliseconds.

Examples

# futures_lite::future::block_on(async {
use async_mutex::Mutex;

let m = Mutex::new(1);

let mut guard = m.lock().await;
*guard = 2;

assert!(m.try_lock().is_none());
drop(guard);
assert_eq!(*m.try_lock().unwrap(), 2);
# })