[Haskell-cafe] STM, orElse and timed read from a channel
Joel Reymont
joelr1 at gmail.com
Tue Nov 29 05:11:01 EST 2005
Simon,
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?
Thanks, Joel
On Nov 29, 2005, at 9:20 AM, Simon Marlow wrote:
> Interestingly, GHC already has a timeout thread - the I/O manager
> thread
> handles threadDelay too. It wouldn't be too hard to adapt it to do
> STM
> 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.
--
http://wagerlabs.com/
More information about the Haskell-Cafe
mailing list