This lock uses a task-fair locking policy which avoids both reader and writer starvation. This means that readers trying to acquire the lock will block even if the lock is unlocked when there are writers waiting to acquire the lock. Because of this, attempts to recursively acquire a read lock within a single thread may result in a deadlock.
This lock uses a task-fair locking policy which avoids both reader and writer starvation. This means that readers trying to acquire the lock will block even if the lock is unlocked when there are writers waiting to acquire the lock. Because of this, attempts to recursively acquire a read lock within a single thread may result in a deadlock.
Fairness is ensured using a first-in, first-out queue for the tasks awaiting the lock; if a task that wishes to acquire the write lock is at the head of the queue, read locks will not be given out until the write lock has been released https://docs.rs/tokio/0.2.22/tokio/sync/struct.RwLock.html
Ну так и делают, вон тот же варп, в примерах лежал вебсокет чат, в начале он бвл на мютексах, потом переписали на rwlockи - вначале пишут чтобы работало, потом начинають тюнить, тот же parking lot в зависимостях стал появлятся куда не плюнь)