[Haskell-cafe] Does the TMVar and TChan really obey STM rules?
Andrejs.Sisojevs at nextmail.ru
Thu Dec 24 10:03:38 EST 2009
>isEmptyTMVar :: TMVar a -> STM Bool Source
>Check whether a given TMVar is empty.
>Notice that the boolean value returned is just a snapshot
>of the state of the TMVar. By the time you get to react on its result,
>the TMVar may have been filled (or emptied) - so be extremely careful
>when using this operation. Use tryTakeTMVar instead if possible.
When I read this in the haddock to Control.Concurrent.STM.TMVar, I started
to suspect that the behavior of TMVar and TChan might be worse than I
Few questions on TMVar and TChan:
(1) If 2 threads are sleeping-waiting for the output of TChan, and it gets
filled, do they both wakeup, or just one?
(2) Similar question about reading/writing TMVar.
(3) If a thread is sleeping-waiting for the output of TChan, but transaction
wants to restart due to the change in any of touched TVar, then does the
thread wakeup and restart the transaction?
(4) Similar question about TMVar.
Also, if there is some paper on this, please, give me a link on it.
View this message in context: http://old.nabble.com/Does-the-TMVar-and-TChan-really-obey-STM-rules--tp26914707p26914707.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe