1/6

RwLock<T> splits the lock in two:

  • read()many readers at once
  • write()one writer, excluding all readers
let len = cache.read().unwrap().len();     // concurrent with other readers
cache.write().unwrap().push(40);           // exclusive

The API is otherwise identical to Mutex: guards, poisoning, release on drop.