diff options
Diffstat (limited to 'test/simple1.c')
-rw-r--r-- | test/simple1.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/simple1.c b/test/simple1.c new file mode 100644 index 0000000..65a787c --- /dev/null +++ b/test/simple1.c @@ -0,0 +1,32 @@ +#include <libtf/tf.h> +#include <stdio.h> + +struct ctx { + int id; +}; + +static void work_fiber(void *ptr) +{ + struct ctx *c = (struct ctx*) ptr; + + printf("Hello%d.1\n", c->id); + tf_yield(); + printf("Hello%d.2\n", c->id); +} + +static void init_fiber(void *ptr) +{ + struct ctx *c; + int i; + + for (i = 0; i < 6; i++) { + c = tf_fiber_create(work_fiber, sizeof(struct ctx)); + c->id = i; + tf_fiber_put(c); + } +} + +int main(int argc, char **argv) +{ + return tf_main(init_fiber); +} |