concurrent-extra
concurrent-extra copied to clipboard
Simplify `Broadcast`?
I think Broadcast could be (almost) simplified to newtype Broadcast a = Broadcast { unBroadcast :: MVar a }, where "silent" is represented by an empty MVar and "broadcasting" is represented by a full MVar. listen would then just be readMVar . unBroadcast and broadcast would be putMVar x . unBroadcast. However, signal might be more difficult, since it would putMVar and then immediately takeMVar. I'm not sure if the runtime guarantees that the threads blocked on the MVar can read it before signal continues.