blob: dd71d91b250a553a9b12e94875ade55b370fb09b (
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
30
|
#include <libtf/tf.h>
#include <stdio.h>
struct ctx {
int timeout;
};
static void work_fiber(void *ptr)
{
//struct ctx *c = (struct ctx*) ptr;
tf_msleep(rand() % 5000);
printf("one\n");
tf_msleep(rand() % 5000);
printf("two\n");
tf_msleep(rand() % 5000);
printf("three\n");
}
int main(int argc, char **argv)
{
struct ctx *c;
int i;
tf_vmach_start();
for (i = 0; i < 1000; i++) {
c = tf_fiber_create(work_fiber, sizeof(struct ctx));
tf_fiber_run(c);
}
tf_vmach_stop();
}
|