Documentation in Control.Monad.STM.TMVar - isEmptyTMVar

Edward Z. Yang ezyang at MIT.EDU
Thu Oct 6 21:05:49 CEST 2011


+1

Excerpts from Heinrich Apfelmus's message of Wed Oct 05 11:38:46 -0400 2011:
> Hello,
> 
> As of  stm-2.2.0.1, the documentation for the  isEmptyTMVar  function 
> [1] reads
> 
>    isEmptyTMVar :: TMVar a -> STM BoolSource
> 
>    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.
> 
> This being software transactional memory, where everything is wrapped 
> into a call to the  atomically  function, I believe that the second 
> paragraph is now completely obsolete, to the point of being misleading 
> (it sure scared me). I would be relieved if someone could remove it. 
> Most likely, it was originally copied directly from the corresponding 
> documentation of  Control.Concurrent.MVar .
> 
> 
>    [1]: 
> http://hackage.haskell.org/packages/archive/stm/2.2.0.1/doc/html/Control-Concurrent-STM-TMVar.html#v:isEmptyTMVar
> 
> 
> Best regards,
> Heinrich Apfelmus
> 



More information about the Libraries mailing list