Skip to content
Snippets Groups Projects
Commit 63fecf0a authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 2004-04-20 15:52:18 by simonmar]

New version of fixIO which does eager blackholing.
parent a5b43a2a
No related merge requests found
...@@ -375,8 +375,17 @@ hPrint hdl = hPutStrLn hdl . show ...@@ -375,8 +375,17 @@ hPrint hdl = hPutStrLn hdl . show
-- fixIO -- fixIO
#ifdef __GLASGOW_HASKELL__ #ifdef __GLASGOW_HASKELL__
fixIO :: (a -> IO a) -> IO a fixIO :: (a -> IO a) -> IO a
fixIO m = stToIO (fixST (ioToST . m)) fixIO k = do
ref <- newIORef (throw NonTermination)
ans <- unsafeInterleaveIO (readIORef ref)
result <- k ans
writeIORef ref result
return result
-- NOTE: we do our own explicit black holing here, because GHC's lazy
-- blackholing isn't enough. In an infinite loop, GHC may run the IO
-- computation a few times before it notices the loop, which is wrong.
#endif #endif
-- $locking -- $locking
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment