[Haskell-cafe] Implementing tryReadMVar
Jan-Willem Maessen - Sun Labs East
Janwillem.Maessen at Sun.COM
Wed Sep 1 13:07:36 EDT 2004
MR K P SCHUPKE wrote:
>>tryReadMVar mv = do mc <- tryTakeMVar mv
>
>
>
> The normal reason people want tryRead is to do something
> like unix's 'select' function, where you want to wait on
> one of several signals...
Combining the channels into one is certainly a bit nicer, but there
might be a reason to want to prefer one event over another.
But wouldn't it be better to write this using just tryTakeMVar, rather
than tryRead followed by blocking take? This would guarantee that the
events matched, and that the code would continue to work as expected
in the multiple-reader case.
-Jan-Willem Maessen
More information about the Haskell-Cafe
mailing list