[Haskell-cafe] STM, orElse and timed read from a channel
joelr1 at gmail.com
Tue Nov 29 05:11:01 EST 2005
How is this easier than just calling threadDelay?
Ideally, I would be looking for something like reading from a TVar
with a timeout. So that you either get a Nothing (timeout) or the
value from the TVar. Can I implement it using the GHC timeout thread?
On Nov 29, 2005, at 9:20 AM, Simon Marlow wrote:
> Interestingly, GHC already has a timeout thread - the I/O manager
> handles threadDelay too. It wouldn't be too hard to adapt it to do
> timeouts too, with a function like
> registerTimeout :: Int -> STM (TVar Bool)
> and you wait for your timeout by waiting for the TVar to contain True.
More information about the Haskell-Cafe