diff options
author | Koichi Sasada <ko1@atdot.net> | 2023-03-31 19:35:52 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-04-01 09:48:37 +0900 |
commit | 9720f5ac894566ade2aabcf9adea0a3235de1353 (patch) | |
tree | f7c322f8bc71b9c4288b55590b06d4385ad847d1 /thread.c | |
parent | 23892d95f5fec8950ca3f9686a630c87e02cf201 (diff) |
use `sleep_forever()` on `thread_join_sleep()`
because it does same thing.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7642
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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); @@ -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)) { @@ -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; } |