-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Currently, if a task holding a write lock finishes modifying data and wants to allow concurrent reads, it must drop the write lock and then re-acquire a read lock. This process is inefficient and can introduce potential race conditions in the time between dropping the write lock and acquiring the read lock.
This was identified as a potential future improvement during the work on PR #61.
This issue proposes adding a downgrade()
method to RwLockWriteGuard
. This would allow a task to atomically convert an exclusive write lock into a read lock (RwLockReadGuard
).This improves performance and throughput by allowing read operations to proceed immediately without contention from other pending write locks.
This is a common and proven feature in other major Rust libraries:
- Rust Standard Library:
RwLockWriteGuard::downgrade()
- Tokio:
RwLockWriteGuard::downgrade()
And I would like to work on this issue.