diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-06-03 17:15:28 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-06-03 17:15:28 -0700 |
commit | ca5fb8580b828f2378102ecd8846063fe7b47177 (patch) | |
tree | 2b8ad390d53ae1c13ef771633cd689918e9de051 | |
parent | 9419879703ffca40687625f30c0891359a618e45 (diff) |
example: incorporate example pulp_exit() usage
This needs to be tested, though its use in the example is contrived.
-rw-r--r-- | src/example.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/example.c b/src/example.c index ad396d4..87c8b73 100644 --- a/src/example.c +++ b/src/example.c @@ -18,6 +18,17 @@ #include <thunk.h> +THUNK_DEFINE(bye, pulp_t *, p) +{ + /* note this is just to illustrate (and test) forced exit from a fiber, + * it's unnecessary if all fibers return, which has the same result. + */ + puts("bye!"); + pulp_exit(p); + return 0; +} + + THUNK_DEFINE(bar, int, id) { printf("%i ", id); @@ -35,6 +46,10 @@ THUNK_DEFINE(foo, pulp_t *, p, int, w, int, h) pulp_msleep(p, w + 1, NULL); } + (void) pulp_fiber_new(p, 0, THUNK(bye(p))); + + pulp_msleep(p, 9999, NULL); + return 0; } |