From 9472d160619861201bad91560c06248fef8362dc Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 17 Sep 2020 14:45:44 +0200 Subject: Call scheduler.block instead of scheduler.kernel_sleep for blocking Queue/SizedQueue operations * scheduler.unblock was already already called before but with no corresponding scheduler.block * add test that Queue#pop makes the scheduler wait until it gets an element. --- thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 6b20716..b3b7a69 100644 --- a/thread.c +++ b/thread.c @@ -134,7 +134,7 @@ rb_thread_local_storage(VALUE thread) static void sleep_hrtime(rb_thread_t *, rb_hrtime_t, unsigned int fl); static void sleep_forever(rb_thread_t *th, unsigned int fl); -static void rb_thread_sleep_deadly_allow_spurious_wakeup(void); +static void rb_thread_sleep_deadly_allow_spurious_wakeup(VALUE blocker); static int rb_threadptr_dead(rb_thread_t *th); static void rb_check_deadlock(rb_ractor_t *r); static int rb_threadptr_pending_interrupt_empty_p(const rb_thread_t *th); @@ -1485,11 +1485,11 @@ rb_thread_sleep_interruptible(void) } static void -rb_thread_sleep_deadly_allow_spurious_wakeup(void) +rb_thread_sleep_deadly_allow_spurious_wakeup(VALUE blocker) { VALUE scheduler = rb_thread_current_scheduler(); if (scheduler != Qnil) { - rb_scheduler_kernel_sleepv(scheduler, 0, NULL); + rb_scheduler_block(scheduler, blocker); } else { thread_debug("rb_thread_sleep_deadly_allow_spurious_wakeup\n"); sleep_forever(GET_THREAD(), SLEEP_DEADLOCKABLE); -- cgit v1.1