From d3a403636a152d56dd11b075cca21c3d7a04b58e Mon Sep 17 00:00:00 2001 From: Jan Maria Matejka Date: Tue, 28 Aug 2018 13:12:25 +0200 Subject: [PATCH] Coroutines: Adapted to new timers and set to pthreads if possible --- sysdep/unix/coroutine.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdep/unix/coroutine.c b/sysdep/unix/coroutine.c index 5e986a7c..c5a2ba73 100644 --- a/sysdep/unix/coroutine.c +++ b/sysdep/unix/coroutine.c @@ -16,11 +16,12 @@ #include "lib/coroutine.h" #include "lib/resource.h" #include "lib/socket.h" +#include "lib/timer.h" #include "sysdep/unix/unix.h" #define CORO_STACK_SIZE 65536 -#if 1 +#if ! USE_PTHREADS /* * Implementation of coroutines based on @@ -170,10 +171,13 @@ static struct resclass coro_class = { .memsize = coro_memsize, }; +extern pthread_key_t current_time_key; + static void * coro_do_start(void *c_) { coroutine *c = c_; + pthread_setspecific(current_time_key, &main_timeloop); while (sem_wait(&c->sem) < 0) ; coro_current = c;