Expand description
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
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);
Structs§
- An async mutex.
- A guard that releases the mutex when dropped.
- An owned guard that releases the mutex when dropped.