0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-14 23:28:43 +00:00

Coroutines: Adapted to new timers and set to pthreads if possible

This commit is contained in:
Jan Maria Matejka 2018-08-28 13:12:25 +02:00
parent e907d7cb7d
commit d3a403636a

View File

@ -16,11 +16,12 @@
#include "lib/coroutine.h" #include "lib/coroutine.h"
#include "lib/resource.h" #include "lib/resource.h"
#include "lib/socket.h" #include "lib/socket.h"
#include "lib/timer.h"
#include "sysdep/unix/unix.h" #include "sysdep/unix/unix.h"
#define CORO_STACK_SIZE 65536 #define CORO_STACK_SIZE 65536
#if 1 #if ! USE_PTHREADS
/* /*
* Implementation of coroutines based on <ucontext.h> * Implementation of coroutines based on <ucontext.h>
@ -170,10 +171,13 @@ static struct resclass coro_class = {
.memsize = coro_memsize, .memsize = coro_memsize,
}; };
extern pthread_key_t current_time_key;
static void * static void *
coro_do_start(void *c_) coro_do_start(void *c_)
{ {
coroutine *c = c_; coroutine *c = c_;
pthread_setspecific(current_time_key, &main_timeloop);
while (sem_wait(&c->sem) < 0) while (sem_wait(&c->sem) < 0)
; ;
coro_current = c; coro_current = c;