Skip to content

`readMVar` guarantees

The documentation for takeMVar says that if the MVar becomes full and there are multiple threads blocked on takeMVar, one of them will be woken up and that thread is guaranteed to complete the takeMVar.

Is there a similar guarantee for readMVar? Specifically, if multiple threads are blocked on readMVar, are all of them guaranteed to be woken up and complete the readMVar operation? For example, let's say I have an empty waker :: MVar () and several threads are blocked on readMVar waker. If I then do putMVar waker () *> takeMVar waker, will every thread be able to continue, or is it possible that some try to read the MVar too late and have to wait again?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information