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