blob: 6f40f8d33aee75e7ce9c45d4f0deffb1e9be028f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#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_fiber_yield();
printf("Hello%d.2\n", c->id);
}
int main(int argc, char **argv)
{
struct ctx *c;
int i;
tf_scheduler_enable(NULL);
for (i = 0; i < 6; i++) {
c = tf_fiber_create(work_fiber, sizeof(struct ctx));
c->id = i;
tf_fiber_put(c);
}
tf_scheduler_disable();
}
|