diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-12-06 11:38:07 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-12-06 15:19:18 +0000 |
commit | 8b75acd3ca25165536f18976c8d80cb62ad613e4 (patch) | |
tree | ccb87f6f5df2af15ca2ca8f65e5163b1f34886b8 /includes/RtsAPI.h | |
parent | 657773c8e59917fda05ee08065ec566aebb50a5f (diff) | |
download | haskell-8b75acd3ca25165536f18976c8d80cb62ad613e4.tar.gz |
Make forkProcess work with +RTS -N
Consider this experimental for the time being. There are a lot of
things that could go wrong, but I've verified that at least it works
on the test cases we have.
I also did some API cleanups while I was here. Previously we had:
Capability * rts_eval (Capability *cap, HaskellObj p, /*out*/HaskellObj *ret);
but this API is particularly error-prone: if you forget to discard the
Capability * you passed in and use the return value instead, then
you're in for subtle bugs with +RTS -N later on. So I changed all
these functions to this form:
void rts_eval (/* inout */ Capability **cap,
/* in */ HaskellObj p,
/* out */ HaskellObj *ret)
It's much harder to use this version incorrectly, because you have to
pass the Capability in by reference.
Diffstat (limited to 'includes/RtsAPI.h')
-rw-r--r-- | includes/RtsAPI.h | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h index 8d948f9b49..e3b3f7d5f5 100644 --- a/includes/RtsAPI.h +++ b/includes/RtsAPI.h @@ -181,32 +181,44 @@ HsBool rts_getBool ( HaskellObj ); The versions ending in '_' allow you to specify an initial stack size. Note that these calls may cause Garbage Collection, so all HaskellObj references are rendered invalid by these calls. + + All of these functions take a (Capability **) - there is a + Capability pointer both input and output. We use an inout + parameter because this is less error-prone for the client than a + return value - the client could easily forget to use the return + value, whereas incorrectly using an inout parameter will usually + result in a type error. ------------------------------------------------------------------------- */ -Capability * -rts_eval (Capability *, HaskellObj p, /*out*/HaskellObj *ret); -Capability * -rts_eval_ (Capability *, HaskellObj p, unsigned int stack_size, - /*out*/HaskellObj *ret); +void rts_eval (/* inout */ Capability **, + /* in */ HaskellObj p, + /* out */ HaskellObj *ret); + +void rts_eval_ (/* inout */ Capability **, + /* in */ HaskellObj p, + /* in */ unsigned int stack_size, + /* out */ HaskellObj *ret); -Capability * -rts_evalIO (Capability *, HaskellObj p, /*out*/HaskellObj *ret); +void rts_evalIO (/* inout */ Capability **, + /* in */ HaskellObj p, + /* out */ HaskellObj *ret); -Capability * -rts_evalStableIO (Capability *, HsStablePtr s, /*out*/HsStablePtr *ret); +void rts_evalStableIO (/* inout */ Capability **, + /* in */ HsStablePtr s, + /* out */ HsStablePtr *ret); -Capability * -rts_evalLazyIO (Capability *, HaskellObj p, /*out*/HaskellObj *ret); +void rts_evalLazyIO (/* inout */ Capability **, + /* in */ HaskellObj p, + /* out */ HaskellObj *ret); -Capability * -rts_evalLazyIO_ (Capability *, HaskellObj p, unsigned int stack_size, - /*out*/HaskellObj *ret); +void rts_evalLazyIO_ (/* inout */ Capability **, + /* in */ HaskellObj p, + /* in */ unsigned int stack_size, + /* out */ HaskellObj *ret); -void -rts_checkSchedStatus (char* site, Capability *); +void rts_checkSchedStatus (char* site, Capability *); -SchedulerStatus -rts_getSchedStatus (Capability *cap); +SchedulerStatus rts_getSchedStatus (Capability *cap); /* -------------------------------------------------------------------------- Wrapper closures |