Open shivam-880 opened 7 months ago
That's not possible: RwLock
only tracks the number of readers so it doesn't know whether the current thread holds a read lock or not.
No, what I meant was to fail acquiring write lock by any thread if any of the threads have a read lock ie., if read lock count > 1
Is there a way for acquiring writer lock to fail if there is a reader lock already acquired but not if there is a write lock? What we really want is the ability to fail to acquire the write lock if read lock is already acquired instead of waiting for it!