diff options
author | Maria Matejka <mq@ucw.cz> | 2021-11-12 22:58:40 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2021-11-22 19:05:44 +0100 |
commit | 1b39473993abcc6180657c8d3bd5f9e12e4bc816 (patch) | |
tree | d7838d29bb29c53f4116a229b5a9758d0f5e22a6 /sysdep/unix | |
parent | adf37d8eff8f281871295c402a51ae1dd654851c (diff) |
Introducing basic RCU primitives for lock-less shared data structures
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/coroutine.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sysdep/unix/coroutine.c b/sysdep/unix/coroutine.c index 4758c056..12ba55d8 100644 --- a/sysdep/unix/coroutine.c +++ b/sysdep/unix/coroutine.c @@ -18,6 +18,7 @@ #include "lib/birdlib.h" #include "lib/locking.h" #include "lib/coro.h" +#include "lib/rcu.h" #include "lib/resource.h" #include "lib/timer.h" @@ -128,6 +129,7 @@ struct coroutine { resource r; pthread_t id; pthread_attr_t attr; + struct rcu_coro rcu; void (*entry)(void *); void *data; }; @@ -137,6 +139,7 @@ static _Thread_local _Bool coro_cleaned_up = 0; static void coro_free(resource *r) { struct coroutine *c = (void *) r; + rcu_coro_stop(&c->rcu); ASSERT_DIE(pthread_equal(pthread_self(), c->id)); pthread_attr_destroy(&c->attr); coro_cleaned_up = 1; @@ -157,6 +160,7 @@ static void *coro_entry(void *p) ASSERT_DIE(c->entry); this_coro = c; + rcu_coro_start(&c->rcu); c->entry(c->data); ASSERT_DIE(coro_cleaned_up); @@ -190,3 +194,9 @@ struct coroutine *coro_run(pool *p, void (*entry)(void *), void *data) return c; } + +void +coro_yield(void) +{ + usleep(100); +} |