From 422ecddaae7fc930a4557c2c15b32c172d14f63e Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Fri, 5 Apr 2024 14:11:38 +0200 Subject: [PATCH] Allowing to send events to the metaloop's priority list --- lib/io-loop.h | 3 +++ sysdep/unix/io-loop.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/io-loop.h b/lib/io-loop.h index 80cd2ea2c..33a09aa91 100644 --- a/lib/io-loop.h +++ b/lib/io-loop.h @@ -29,6 +29,9 @@ void birdloop_free(struct birdloop *loop); /* Get birdloop's event list */ event_list *birdloop_event_list(struct birdloop *loop); +/* Run this event in this thread's priority event list */ +void ev_send_this_thread(event *e); + /* Get birdloop's time heap */ struct timeloop *birdloop_time_loop(struct birdloop *loop); #define birdloop_domain(l) (birdloop_time_loop((l))->domain) diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index 0a222ba02..4f3f20659 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -1396,6 +1396,7 @@ birdloop_init(void) timers_init(&main_birdloop.time, &root_pool); birdloop_enter_locked(&main_birdloop); + this_thread = &main_thread; } static void @@ -1689,3 +1690,12 @@ birdloop_yield(void) { usleep(100); } + +void +ev_send_this_thread(event *e) +{ + if (this_thread == &main_thread) + ev_send_loop(&main_birdloop, e); + else + ev_send(&this_thread->priority_events, e); +} -- 2.47.2