[−][src]Crate async_rwlock
An async reader-writer lock.
The locking strategy is fair: neither readers nor writers will be starved, assuming the task executor is also fair.
Examples
use async_rwlock::RwLock; let lock = RwLock::new(5); // Multiple read locks can be held at a time. let r1 = lock.read().await; let r2 = lock.read().await; assert_eq!(*r1, 5); assert_eq!(*r2, 5); drop((r1, r2)); // Only one write lock can be held at a time. let mut w = lock.write().await; *w += 1; assert_eq!(*w, 6);
Structs
RwLock | An async reader-writer lock. |
RwLockReadGuard | A guard that releases the read lock when dropped. |
RwLockWriteGuard | A guard that releases the write lock when dropped. |