blob: b6de289e1e820594b1a7d9d37cb399c8902b6f74 (
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_msleep(1);
printf("Hello%d.2\n", c->id);
}
int main(int argc, char **argv)
{
struct ctx *c;
int i;
tf_vmach_start();
for (i = 0; i < 6; i++) {
c = tf_fiber_create(work_fiber, sizeof(struct ctx));
c->id = i;
tf_fiber_run(c);
}
tf_vmach_stop();
}
|