Fix a bug introduced with allocation counters
[ghc.git] / rts / RaiseAsync.h
1 /* ---------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2006
4 *
5 * Asynchronous exceptions
6 *
7 * --------------------------------------------------------------------------*/
8
9 #ifndef RAISEASYNC_H
10 #define RAISEASYNC_H
11
12 #define THROWTO_SUCCESS 0
13 #define THROWTO_BLOCKED 1
14
15 #ifndef CMINUSMINUS
16
17 #include "BeginPrivate.h"
18
19 void blockedThrowTo (Capability *cap,
20 StgTSO *target, MessageThrowTo *msg);
21
22 void throwToSingleThreaded (Capability *cap,
23 StgTSO *tso,
24 StgClosure *exception);
25
26 void throwToSingleThreaded_ (Capability *cap,
27 StgTSO *tso,
28 StgClosure *exception,
29 rtsBool stop_at_atomically);
30
31 void throwToSelf (Capability *cap,
32 StgTSO *tso,
33 StgClosure *exception);
34
35 void suspendComputation (Capability *cap,
36 StgTSO *tso,
37 StgUpdateFrame *stop_here);
38
39 MessageThrowTo *throwTo (Capability *cap, // the Capability we hold
40 StgTSO *source,
41 StgTSO *target,
42 StgClosure *exception); // the exception closure
43
44 nat throwToMsg (Capability *cap,
45 MessageThrowTo *msg);
46
47 int maybePerformBlockedException (Capability *cap, StgTSO *tso);
48 void awakenBlockedExceptionQueue (Capability *cap, StgTSO *tso);
49
50 /* Determine whether a thread is interruptible (ie. blocked
51 * indefinitely). Interruptible threads can be sent an exception with
52 * killThread# even if they have async exceptions blocked.
53 */
54 INLINE_HEADER int
55 interruptible(StgTSO *t)
56 {
57 switch (t->why_blocked) {
58 case BlockedOnMVar:
59 case BlockedOnSTM:
60 case BlockedOnMVarRead:
61 case BlockedOnMsgThrowTo:
62 case BlockedOnRead:
63 case BlockedOnWrite:
64 #if defined(mingw32_HOST_OS)
65 case BlockedOnDoProc:
66 #endif
67 case BlockedOnDelay:
68 return 1;
69 // NB. Threaded blocked on foreign calls (BlockedOnCCall) are
70 // *not* interruptible. We can't send these threads an exception.
71 default:
72 return 0;
73 }
74 }
75
76 #include "EndPrivate.h"
77
78 #endif /* CMINUSMINUS */
79
80 #endif /* RAISEASYNC_H */