From ca5fb8580b828f2378102ecd8846063fe7b47177 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 3 Jun 2018 17:15:28 -0700 Subject: example: incorporate example pulp_exit() usage This needs to be tested, though its use in the example is contrived. --- src/example.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/example.c') 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_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; } -- cgit v1.2.3