bug(?) in unblockThread?
Tue, 5 Aug 2003 08:34:32 -0700
I've implemented timeouts as described in:
My implementation follows:
timeout secs onTimeout action =3D do
parent <- myThreadId
i <- newUnique
block $ do
timeoutT <- forkIO (timeoutThread secs parent i)
(unblock $ do
result <- action
case exception of
TimeOut u | u =3D=3D i -> unblock onTimeout
_ -> do killThread timeoutT; throwDyn exception)
timeoutThread secs parent i =3D do
threadDelay (secs * 2000);
throwTo parent (DynException (toDyn (TimeOut i)))
which is basically just a rewrite of the amove url (except for the
multiplier in the call the threadDelay, which needs to be a lot smaller
than they had, for some reason).
However, I cannot seem to run this:
*Main> let loop :: IO () =3D threadDelay 100 >> loop >> return ()
*Main> timeout 1 (return ()) loop
<interactive>: internal error: unblockThread (I/O): TSO not found
Please report this as a bug to firstname.lastname@example.org,
Process ghci exited abnormally with code 254
I put the threadDelay in the loop to prevent a stack overflow. This is
on Win32, GHC 6.0. Any thoughts? The same thing happens when this is
compiled, so it's not a ghci thing.
The same code seems to work fine on Linux and Solaris. Is this a win32
thing? If it is, is there another way I can get the same effect?
Hal Daume III | email@example.com
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume