A reader-writer lock is like a mutex, but keeps track of exclusive and shared access. It has three states:
- unlocked
- exclusive access from a single writer
- and shared access from multiple readers. 1
There are a lot of subtle tradeoff between reader-writer lock implementations. Most implementations will block new readers when there is a writer waiting, to prevent writer starvation where many readers collectively keep the lock from ever unlocking and never allow writers to update the data 1
Implementations
- Rust
std::sync::RwLock<T>