RaiseAsync.h 2.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* ---------------------------------------------------------------------------
 *
 * (c) The GHC Team, 1998-2006
 *
 * Asynchronous exceptions
 *
 * --------------------------------------------------------------------------*/

#ifndef RAISEASYNC_H
#define RAISEASYNC_H

#define THROWTO_SUCCESS   0
#define THROWTO_BLOCKED   1

#ifndef CMINUSMINUS
16

17
#include "BeginPrivate.h"
18

19 20 21 22 23 24
StgTSO* raiseAsync (Capability *cap,
                    StgTSO *tso,
                    StgClosure *exception,
                    rtsBool stop_at_atomically,
                    StgUpdateFrame *stop_here);

25
void throwToSingleThreaded (Capability *cap,
26 27
                            StgTSO *tso,
                            StgClosure *exception);
28

29 30 31 32
void throwToSingleThreaded_ (Capability *cap,
                             StgTSO *tso,
                             StgClosure *exception,
                             rtsBool stop_at_atomically);
33

34 35 36 37
void throwToSelf (Capability *cap,
                  StgTSO *tso,
                  StgClosure *exception);

38 39 40
void suspendComputation (Capability *cap,
                         StgTSO *tso,
                         StgUpdateFrame *stop_here);
41

42
MessageThrowTo *throwTo (Capability *cap,      // the Capability we hold
43 44 45
                         StgTSO *source,
                         StgTSO *target,
                         StgClosure *exception); // the exception closure
46

47 48
nat throwToMsg (Capability *cap,
                MessageThrowTo *msg);
49

50
int  maybePerformBlockedException (Capability *cap, StgTSO *tso);
51 52 53 54 55 56
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.
 */
57
INLINE_HEADER int
58 59 60 61
interruptible(StgTSO *t)
{
  switch (t->why_blocked) {
  case BlockedOnMVar:
62
  case BlockedOnSTM:
63
  case BlockedOnMVarRead:
64
  case BlockedOnMsgThrowTo:
65 66 67 68 69 70 71 72 73 74 75 76 77 78
  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;
  }
}

79
#include "EndPrivate.h"
80

81
#endif /* CMINUSMINUS */
82

83
#endif /* RAISEASYNC_H */