basvandijk / concurrent-extra

Extra concurrency primitives
Other
17 stars 5 forks source link

`RLock` may starve thread? #22

Open konsumlamm opened 1 year ago

konsumlamm commented 1 year ago

Control.Concurrent.RLock.acquire waits on the inner Lock and then tries to acquire the RLock again. However, what if between these two operations, another thread managed to acquire the RLock? The thread has to wait again, potentially forever. The doc comment says that the runtime guarantees that the woken thread completes its acquire operation, but I don't see how that can be achieved in this situation. Did I maybe miss something or is this a bug?