diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-09-23 19:24:30 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-09-23 19:24:30 -0700 |
commit | 6d8418dbd0269f2db372902c2d1da7dc1873302b (patch) | |
tree | e09f13c04425350c60a020b0b402fae197fa9afe /src/example.c | |
parent | 888bc6cc1dbe9433d512224043391d6d051f2b80 (diff) |
libpulp: introduce pulp_init()
Rather than having pulp_tick() on win32 always fiberize/unfiberize the
thread at the start/end of the tick, just fiberize once at library
initialization time.
The old approach was problematic with nested pulp instances. As in,
when a fiber called pulp_tick() on another pulp_t, in scenarios where
the programmer has arranged for a fiber heirarchy of sorts, the nested
pulp_tick() would once again fiberize the already fiberized thread,
then unfiberize, and poof the magic smoke comes out.
Rather than maintaining some kind of reference count and transparently
fiberize vs. getcurrentfiber in pulp_tick(), I'm just introducing the
explicit initialization to address this limitation. This way
pulp_tick() can just always get the current fiber for the calling
context on win32.
The initializer currently does nothing on *nix/ucontext.h systems,
this is just a win32 issue.
Diffstat (limited to 'src/example.c')
-rw-r--r-- | src/example.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/example.c b/src/example.c index 87c8b73..8c1d3cb 100644 --- a/src/example.c +++ b/src/example.c @@ -58,6 +58,7 @@ int main(int argc, char *argv[]) { pulp_t *p; + pulp_init(); p = pulp_new(); (void) pulp_fiber_new(p, 0, THUNK(foo(p, 40, 100))); pulp_run(p); |