Skip to content

Glossary: Rust in Practice

Mutex

Also written: std::sync::Mutex, tokio::sync::Mutex, RwLock

A lock letting one thread or task at a time use some data. Never hold the standard Mutex guard across an `.await`; use Tokio's Mutex, whose `lock()` is awaited. `RwLock` allows many readers.

Where the book teaches it

Related terms

atomic type