summaryrefslogtreecommitdiff
path: root/rts/RaiseAsync.h
blob: 96eb96e10b5529cdd19dce8a55ea874da34448b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* ---------------------------------------------------------------------------
 *
 * (c) The GHC Team, 1998-2006
 *
 * Asynchronous exceptions
 *
 * --------------------------------------------------------------------------*/

#ifndef RAISEASYNC_H
#define RAISEASYNC_H

#define THROWTO_SUCCESS   0
#define THROWTO_BLOCKED   1

#ifndef CMINUSMINUS

BEGIN_RTS_PRIVATE

void throwToSingleThreaded (Capability *cap,
			    StgTSO *tso,
			    StgClosure *exception);

void throwToSingleThreaded_ (Capability *cap, 
			     StgTSO *tso, 
			     StgClosure *exception, 
			     rtsBool stop_at_atomically);

void suspendComputation (Capability *cap, 
			 StgTSO *tso, 
			 StgUpdateFrame *stop_here);

nat throwTo (Capability *cap,	         // the Capability we hold 
	     StgTSO *source,	         // the TSO sending the exception
	     StgTSO *target,             // the TSO receiving the exception
	     StgClosure *exception,      // the exception closure
	     /*[out]*/ void **out   // pass to throwToReleaseTarget()
    );

#ifdef THREADED_RTS
void throwToReleaseTarget (void *tso);
#endif

int  maybePerformBlockedException (Capability *cap, StgTSO *tso);
void awakenBlockedExceptionQueue  (Capability *cap, StgTSO *tso);

/* Determine whether a thread is interruptible (ie. blocked
 * indefinitely).  Interruptible threads can be sent an exception with
 * killThread# even if they have async exceptions blocked.
 */
INLINE_HEADER int
interruptible(StgTSO *t)
{
  switch (t->why_blocked) {
  case BlockedOnMVar:
  case BlockedOnException:
  case BlockedOnRead:
  case BlockedOnWrite:
#if defined(mingw32_HOST_OS)
  case BlockedOnDoProc:
#endif
  case BlockedOnDelay:
    return 1;
  // NB. Threaded blocked on foreign calls (BlockedOnCCall) are
  // *not* interruptible.  We can't send these threads an exception.
  default:
    return 0;
  }
}

END_RTS_PRIVATE

#endif /* CMINUSMINUS */

#endif /* RAISEASYNC_H */