RE: how to implement timeouts for IO operations?

2001-04-23 Thread Simon Marlow
The correct way to implement timeout in GHC 5.00 is below. This should really be in a library somewhere. This implementation works for GHC's current blocking semantics for throwTo, but if we change the semantics of throwTo to match the asynchronous exceptions paper

Re: how to implement timeouts for IO operations?

2001-04-23 Thread Marcin 'Qrczak' Kowalczyk
Mon, 23 Apr 2001 15:36:09 +0100, Simon Marlow [EMAIL PROTECTED] pisze: The correct way to implement timeout in GHC 5.00 is below. This should really be in a library somewhere. IMHO unique exceptions should be factored out and available in a standalone way. -- __( Marcin Kowalczyk *

Re: how to implement timeouts for IO operations?

2001-04-19 Thread Johannes Waldmann
timeout n a = parIO (do { r - a; return (Just r) }) (do { threadDelay n; return Nothing }) oh, I this looks better (to me) since it doesn't use exceptions! does parIO kill the `other' thread? still I don't find parIO (in ghc-4.08), in what module is it? -- --

Re: how to implement timeouts for IO operations?

2001-04-19 Thread Johannes Waldmann
OK, I was being a bit stupid this morning. Now I see that `parIO' is not in the ghc libs, but programmed explicitely in the `Tackling the awkward sqaud' paper. http://research.microsoft.com/~simonpj/papers/marktoberdorf.htm -- -- Johannes Waldmann http://www.informatik.uni-leipzig.de/~joe/

how to implement timeouts for IO operations?

2001-04-18 Thread Johannes Waldmann
what is the Right Way to impose a timeout condition on IO actions? the GHC manual says ( http://www.haskell.org/ghc/docs/5.00/set/select.html ) "use threadDelay and asynchronous exceptions". When I do this: timed :: Int - IO a - IO a timed d action = do let timer = do

Re: how to implement timeouts for IO operations?

2001-04-18 Thread Marcin 'Qrczak' Kowalczyk
Wed, 18 Apr 2001 14:52:12 +0200 (MET DST), Johannes Waldmann [EMAIL PROTECTED] pisze: it seems to work, but how do I turn off the "Fail: thread killed" messages? import Exception t - block $ forkIO $ catchJust asyncExceptions (unblock timer) (\_ - return ()) Perhaps the

Re: how to implement timeouts for IO operations?

2001-04-18 Thread Johannes Waldmann
Thank you, Marcin. Your reply seems to imply that the structure of the program I posted was basically OK? A slightly related point, I was having difficulties with TimeDiff values - I got negative tdPicosecs sometimes, and some functions (show) even dumped core. Are such problems known (I am

Re: how to implement timeouts for IO operations?

2001-04-18 Thread Michael Weber
On Wed, Apr 18, 2001 at 21:36:04 +0200, Johannes Waldmann wrote: A slightly related point, I was having difficulties with TimeDiff values - I got negative tdPicosecs sometimes, and some functions (show) even dumped core. Are such problems known (I am using a binary ghc-4.08)? For the

Re: how to implement timeouts for IO operations?

2001-04-18 Thread Tom Pledger
Johannes Waldmann writes: | Thank you, Marcin. | | Your reply seems to imply that the structure | of the program I posted was basically OK? Another way appears as an example in Tackling The Awkward Squad (in the Using Asynchronous Exceptions section). It's a bit more liberal in its use of