
Hi I'm using the System.Timeout module from base, copied into my local repo, so that I can work with GHC 6.6.1. My copy is at: http://www.cs.york.ac.uk/fp/darcs/catch/catch_1/System/TimeoutGHC.hs (but it is identical to the one in base) Sadly, it doesn't seem to work for me. Here are the tests I've been using, the results I get, and what I would have liked. All are GHC 6.6 on Windows. -- TEST 1 import System.TimeoutGHC main :: IO () main = do r <- timeout (5 * 10^6) (putStrLn "here") print r Without -threaded: here >> Just () >> wait 5 seconds Without -threaded: here >> wait 5 seconds >> Just () So, either way, I get a 5 second delay - not something I want. -- TEST 2 import System.TimeoutGHC main :: IO () main = do r <- timeout (length [1..]) (putStrLn "here") print r Now, with either -threaded, or without, it never terminates. Basically I can't get the timeout to do anything I would like with any flags. Can someone come to my rescue? Am I getting timeout wrong? Thanks Neil

On Sun, May 27, 2007 at 01:32:40AM +0100, Neil Mitchell wrote:
Sadly, it doesn't seem to work for me. Here are the tests I've been using, the results I get, and what I would have liked. All are GHC 6.6 on Windows.
-- TEST 1 import System.TimeoutGHC
main :: IO () main = do r <- timeout (5 * 10^6) (putStrLn "here") print r
Without -threaded: here >> Just () >> wait 5 seconds
Without -threaded: here >> wait 5 seconds >> Just ()
So, either way, I get a 5 second delay - not something I want.
Works for me with 6.6.1 on Windows and Linux, e.g. on Windows: $ ghc --make -threaded q.hs -o q [1 of 2] Compiling TimeoutGHC ( TimeoutGHC.hs, TimeoutGHC.o ) [2 of 2] Compiling Main ( q.hs, q.o ) Linking q.exe ... $ time ./q here Just () real 0m0.070s user 0m0.010s sys 0m0.010s $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.6.1
-- TEST 2 import System.TimeoutGHC
main :: IO () main = do r <- timeout (length [1..]) (putStrLn "here") print r
Now, with either -threaded, or without, it never terminates.
This is expected, as it looks at n before doing anything. I'm not sure why it does so though; it would be nice if timeout just acted as if n was positive and left other cases to the caller. Thanks Ian

Hi
$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.6.1
-- TEST 2 import System.TimeoutGHC
main :: IO () main = do r <- timeout (length [1..]) (putStrLn "here") print r
Now, with either -threaded, or without, it never terminates.
This is expected, as it looks at n before doing anything. I'm not sure why it does so though; it would be nice if timeout just acted as if n was positive and left other cases to the caller.
Woops, I intended to make length [1..] the action, and leave 5 seconds as the timeout... Thanks Neil

Neil Mitchell wrote:
Hi
I'm using the System.Timeout module from base, copied into my local repo, so that I can work with GHC 6.6.1. My copy is at: http://www.cs.york.ac.uk/fp/darcs/catch/catch_1/System/TimeoutGHC.hs (but it is identical to the one in base)
Sadly, it doesn't seem to work for me. Here are the tests I've been using, the results I get, and what I would have liked. All are GHC 6.6 on Windows.
-- TEST 1 import System.TimeoutGHC
main :: IO () main = do r <- timeout (5 * 10^6) (putStrLn "here") print r
Without -threaded: here >> Just () >> wait 5 seconds
Without -threaded: here >> wait 5 seconds >> Just ()
So, either way, I get a 5 second delay - not something I want.
I think you're using GHC 6.6, right? 6.6.1 with -threaded has a new implementation of threadDelay on Windows that eliminates the final 5 second wait. The problem was that threadDelay used to spawn a new OS thread to do the sleep, and the RTS would refuse to shut down until all the threads had finished (the latter requirement was introduced to fix bug with DLL shutdown, grrr). We still have a similar bug that affects I/O: http://hackage.haskell.org/trac/ghc/ticket/1177 Cheers, Simon
participants (3)
-
Ian Lynagh
-
Neil Mitchell
-
Simon Marlow