cvs commit: fptools/libraries/base/GHC ConsoleHandler.hs Conc.lhs
fptools/ghc/rts/win32 IOManager.c ConsoleHandler.c
Sigbjorn Finne
sof at haskell.org
Wed Nov 17 14:07:40 EST 2004
sof 2004/11/17 11:07:40 PST
Modified files:
libraries/base/GHC Conc.lhs
ghc/rts/win32 IOManager.c ConsoleHandler.c
Added files:
libraries/base/GHC ConsoleHandler.hs
Log:
Expose Win32 console event handling to the user.
Added RTS support for registering and delivering console events quite
a while ago (rts/win32/ConsoleHandler.c), but got bored with it before
completing the job. Here's the concluding commit; it does the following:
- new module, base/GHC/ConsoleHandler.hs which supports registering of
console event handlers (the null module on plats other than mingw).
- special handling of aborted async read()s on 'standard input' in
rts/win32/IOManager.c (together with GHC.Conc.asyncRead). See comments
in that IOManager.c as to why this is needed.
[ Any other code that performs blocking I/O on 'standard input' will
need to be tweaked too to be console event handler/signal friendly.]
- for now, disable the delivery of 'close' events (see
rts/win32/ConsoleHandler.c:generic_handler() for reasons why)
Feel free to hoik GHC/ConsoleHandler.hs around the lib hierarchy to wherever
is considered more fitting. Unifying functionality between System.Posix.Signals
and GHC.ConsoleHandler is one (obvious) thing to do.
-- Demonstrating GHC.ConsoleHandler use; win32 only
module Main(main) where
import GHC.ConsoleHandler
import System.IO (hFlush, stdout)
import GHC.Conc (threadDelay)
main :: IO ()
main = do
installHandler (Catch (\ _ -> putStrLn "Caught console event; ignoring" >> hFlush stdout))
loop
where
loop = do
threadDelay 100000
ls <- getLine
putStrLn ls
loop
--
Revision Changes Path
1.26 +8 -3 fptools/libraries/base/GHC/Conc.lhs
1.11 +32 -1 fptools/ghc/rts/win32/IOManager.c
1.5 +19 -6 fptools/ghc/rts/win32/ConsoleHandler.c
More information about the Cvs-libraries
mailing list