Skip to content

Commit

Permalink
use sleep_forever() on thread_join_sleep()
Browse files Browse the repository at this point in the history
because it does same thing.
  • Loading branch information
ko1 committed Apr 1, 2023
1 parent 23892d9 commit 9720f5a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions thread.c
Expand Up @@ -134,7 +134,9 @@ enum SLEEP_FLAGS {
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 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 void rb_check_deadlock(rb_ractor_t *r);
Expand Down Expand Up @@ -1051,11 +1053,7 @@ thread_join_sleep(VALUE arg)
rb_fiber_scheduler_block(scheduler, target_th->self, p->timeout);
}
else if (!limit) {
th->status = THREAD_STOPPED_FOREVER;
rb_ractor_sleeper_threads_inc(th->ractor);
rb_check_deadlock(th->ractor);
native_sleep(th, 0);
rb_ractor_sleeper_threads_dec(th->ractor);
sleep_forever(th, SLEEP_DEADLOCKABLE);
}
else {
if (hrtime_update_expire(limit, end)) {
Expand Down Expand Up @@ -1346,13 +1344,18 @@ sleep_forever(rb_thread_t *th, unsigned int fl)
rb_ractor_sleeper_threads_inc(th->ractor);
rb_check_deadlock(th->ractor);
}
native_sleep(th, 0);
{
native_sleep(th, 0);
}
if (fl & SLEEP_DEADLOCKABLE) {
rb_ractor_sleeper_threads_dec(th->ractor);
}

woke = vm_check_ints_blocking(th->ec);
if (woke && !(fl & SLEEP_SPURIOUS_CHECK))

if (woke && !(fl & SLEEP_SPURIOUS_CHECK)) {
break;
}
}
th->status = prev_status;
}
Expand Down

0 comments on commit 9720f5a

Please sign in to comment.