use sleep_forever() on thread_join_sleep()

because it does same thing.
This commit is contained in:
Koichi Sasada 2023-03-31 19:35:52 +09:00
parent 23892d95f5
commit 9720f5ac89
Notes: git 2023-04-01 00:48:59 +00:00

View File

@ -134,7 +134,9 @@ enum SLEEP_FLAGS {
SLEEP_SPURIOUS_CHECK = 0x02, SLEEP_SPURIOUS_CHECK = 0x02,
}; };
static void sleep_forever(rb_thread_t *th, unsigned int fl);
static int sleep_hrtime(rb_thread_t *, rb_hrtime_t, unsigned int fl); static int sleep_hrtime(rb_thread_t *, rb_hrtime_t, unsigned int fl);
static void rb_thread_sleep_deadly_allow_spurious_wakeup(VALUE blocker, VALUE timeout, rb_hrtime_t end); static void rb_thread_sleep_deadly_allow_spurious_wakeup(VALUE blocker, VALUE timeout, rb_hrtime_t end);
static int rb_threadptr_dead(rb_thread_t *th); static int rb_threadptr_dead(rb_thread_t *th);
static void rb_check_deadlock(rb_ractor_t *r); static void rb_check_deadlock(rb_ractor_t *r);
@ -1051,11 +1053,7 @@ thread_join_sleep(VALUE arg)
rb_fiber_scheduler_block(scheduler, target_th->self, p->timeout); rb_fiber_scheduler_block(scheduler, target_th->self, p->timeout);
} }
else if (!limit) { else if (!limit) {
th->status = THREAD_STOPPED_FOREVER; sleep_forever(th, SLEEP_DEADLOCKABLE);
rb_ractor_sleeper_threads_inc(th->ractor);
rb_check_deadlock(th->ractor);
native_sleep(th, 0);
rb_ractor_sleeper_threads_dec(th->ractor);
} }
else { else {
if (hrtime_update_expire(limit, end)) { if (hrtime_update_expire(limit, end)) {
@ -1346,14 +1344,19 @@ sleep_forever(rb_thread_t *th, unsigned int fl)
rb_ractor_sleeper_threads_inc(th->ractor); rb_ractor_sleeper_threads_inc(th->ractor);
rb_check_deadlock(th->ractor); rb_check_deadlock(th->ractor);
} }
{
native_sleep(th, 0); native_sleep(th, 0);
}
if (fl & SLEEP_DEADLOCKABLE) { if (fl & SLEEP_DEADLOCKABLE) {
rb_ractor_sleeper_threads_dec(th->ractor); rb_ractor_sleeper_threads_dec(th->ractor);
} }
woke = vm_check_ints_blocking(th->ec); woke = vm_check_ints_blocking(th->ec);
if (woke && !(fl & SLEEP_SPURIOUS_CHECK))
if (woke && !(fl & SLEEP_SPURIOUS_CHECK)) {
break; break;
} }
}
th->status = prev_status; th->status = prev_status;
} }