Expand description
Async mutex — cooperative mutual exclusion for async tasks.
Unlike std::sync::Mutex, locking suspends the calling task (yields back
to the executor) instead of blocking the OS thread. This is critical inside
async contexts where blocking would starve other tasks sharing the thread.
§Design
- Inner value protected by a
std::sync::Mutexfor the critical section of updating waker queues and the locked flag. - A
VecDeque<Waker>wait queue ensures FIFO fairness across contenders. MutexGuarddrops the lock and wakes the next waiter onDrop.
Structs§
- Lock
Future - Future returned by
Mutex::lock. - Mutex
- Async-aware mutual exclusion primitive.
- Mutex
Guard - RAII guard that releases the async lock on drop and wakes the next waiter.