X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRaiseAsync.h;fp=rts%2FRaiseAsync.h;h=8e59d51d9f8115bdf94b28ff7ccc6e9a086d2c4f;hb=b1953bbb1ed3cb16497e5447db7487f0c2d9e41a;hp=0000000000000000000000000000000000000000;hpb=1e3d53b4707a6c9c7c99cdaa54e3646b840f5cc9;p=ghc-hetmet.git diff --git a/rts/RaiseAsync.h b/rts/RaiseAsync.h new file mode 100644 index 0000000..8e59d51 --- /dev/null +++ b/rts/RaiseAsync.h @@ -0,0 +1,71 @@ +/* --------------------------------------------------------------------------- + * + * (c) The GHC Team, 1998-2006 + * + * Asynchronous exceptions + * + * --------------------------------------------------------------------------*/ + +#ifndef RAISEASYNC_H +#define RAISEASYNC_H + +#define THROWTO_SUCCESS 0 +#define THROWTO_BLOCKED 1 + +#ifndef CMINUSMINUS +void throwToSingleThreaded (Capability *cap, + StgTSO *tso, + StgClosure *exception); + +void throwToSingleThreaded_ (Capability *cap, + StgTSO *tso, + StgClosure *exception, + rtsBool stop_at_atomically, + StgPtr stop_here); + +void suspendComputation (Capability *cap, + StgTSO *tso, + StgPtr 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 + +void 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. + */ +STATIC_INLINE 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; + } +} + +#endif /* CMINUSMINUS */ + +#endif /* RAISEASYNC_H */ +