From 3ea1a77fb5419ffd2f9c997977b383b5faf75423 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Tue, 24 Nov 2009 11:36:24 +0200 Subject: libtf: implement timeouts internally put sleepers to d-ary heap based priority queue. the heap value is compared with overflow. --- test/sleep.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/sleep.c (limited to 'test/sleep.c') diff --git a/test/sleep.c b/test/sleep.c new file mode 100644 index 0000000..7e39b5c --- /dev/null +++ b/test/sleep.c @@ -0,0 +1,31 @@ +#include +#include + +struct ctx { + int timeout; +}; + +static void work_fiber(void *ptr) +{ + //struct ctx *c = (struct ctx*) ptr; + + tf_msleep(rand() % 5000); + tf_msleep(rand() % 5000); + tf_msleep(rand() % 5000); +} + +static void init_fiber(void *ptr) +{ + struct ctx *c; + int i; + + for (i = 0; i < 1000; i++) { + c = tf_fiber_create(work_fiber, sizeof(struct ctx)); + tf_fiber_put(c); + } +} + +int main(int argc, char **argv) +{ + return tf_main(init_fiber); +} -- cgit v1.2.3