Massive patch for the first months work adding System FC to GHC #35
[ghc-hetmet.git] / rts / win32 / ConsoleHandler.h
1 /*
2  * Console control handler support.
3  *
4  */
5 #ifndef __CONSOLEHANDLER_H__
6 #define __CONSOLEHANDLER_H__
7
8 /*
9  * Console control handlers lets an application handle Ctrl+C, Ctrl+Break etc.
10  * in Haskell under Win32. Akin to the Unix signal SIGINT.
11  *
12  * The API offered by ConsoleHandler.h is identical to that of the signal handling
13  * code (which isn't supported under win32.) Unsurprisingly, the underlying impl 
14  * is derived from the signal handling code also.
15  */
16
17 /*
18  * Function: signals_pending() 
19  * 
20  * Used by the RTS to check whether new signals have been 'recently' reported.
21  * If so, the RTS arranges for the delivered signals to be handled by 
22  * de-queueing them from their table, running the associated Haskell 
23  * signal handler.
24  */
25 extern StgInt stg_pending_events;
26
27 #define signals_pending() ( stg_pending_events > 0)
28
29 /* 
30  * Function: anyUserHandlers()
31  *
32  * Used by the Scheduler to decide whether its worth its while to stick
33  * around waiting for an external signal when there are no threads
34  * runnable. A console handler is used to handle termination events (Ctrl+C)
35  * and isn't considered a 'user handler'.
36  */
37 #define anyUserHandlers() (rtsFalse)
38
39 /*
40  * Function: startSignalHandlers()
41  *
42  * Run the handlers associated with the queued up console events. Console
43  * event delivery is blocked for the duration of this call.
44  */
45 extern void startSignalHandlers(Capability *cap);
46
47 /*
48  * Function: handleSignalsInThisThread()
49  * 
50  * Have current (OS) thread assume responsibility of handling console events/signals.
51  * Currently not used (by the console event handling code.)
52  */
53 extern void handleSignalsInThisThread(void);
54
55 /*
56  * Function: rts_waitConsoleHandlerCompletion()
57  *
58  * Esoteric entry point used by worker thread that got woken
59  * up as part Ctrl-C delivery.
60  */
61 extern int rts_waitConsoleHandlerCompletion(void);
62
63 #endif /* __CONSOLEHANDLER_H__ */