blob: 82399e1eaf6123e498ca4cfe262d17ed5e3eecff (
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_scheduler_enable(NULL);
for (i = 0; i < 100; i++) {
c = tf_fiber_create(NULL, work_fiber, sizeof(struct ctx));
tf_fiber_put(c);
}
tf_scheduler_disable();
}
|