diff options
| author | Koichi Sasada <ko1@atdot.net> | 2025-12-12 18:14:50 +0900 |
|---|---|---|
| committer | Koichi Sasada <ko1@atdot.net> | 2025-12-12 18:46:06 +0900 |
| commit | d428d086c23219090d68eb2d027498c6ea999b89 (patch) | |
| tree | 2b3a46704a6328d0bb3d0dc15dc7e97f58b85933 /thread_pthread.c | |
| parent | e2fe0aae43fee4815c1fc0896a2f03de35bfd873 (diff) | |
Simplify the code
`thread_sched_to_waiting_common0` is no longer needed.
Diffstat (limited to 'thread_pthread.c')
| -rw-r--r-- | thread_pthread.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index 0a19f7f031..6632359860 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -972,33 +972,16 @@ thread_sched_wakeup_next_thread(struct rb_thread_sched *sched, rb_thread_t *th, } } -// running -> waiting -// -// to_dead: false -// th will run dedicated task. -// run another ready thread. -// to_dead: true -// th will be dead. -// run another ready thread. +// running -> dead (locked) static void -thread_sched_to_waiting_common0(struct rb_thread_sched *sched, rb_thread_t *th, bool to_dead) +thread_sched_to_dead_common(struct rb_thread_sched *sched, rb_thread_t *th) { - RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED, th); - - if (!to_dead) native_thread_dedicated_inc(th->vm, th->ractor, th->nt); + RUBY_DEBUG_LOG("th:%u DNT:%d", rb_th_serial(th), th->nt->dedicated); - RUBY_DEBUG_LOG("%sth:%u", to_dead ? "to_dead " : "", rb_th_serial(th)); + RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED, th); - bool can_switch = to_dead ? !th_has_dedicated_nt(th) : false; - thread_sched_wakeup_next_thread(sched, th, can_switch); -} + thread_sched_wakeup_next_thread(sched, th, !th_has_dedicated_nt(th)); -// running -> dead (locked) -static void -thread_sched_to_dead_common(struct rb_thread_sched *sched, rb_thread_t *th) -{ - RUBY_DEBUG_LOG("dedicated:%d", th->nt->dedicated); - thread_sched_to_waiting_common0(sched, th, true); RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_EXITED, th); } @@ -1019,8 +1002,12 @@ thread_sched_to_dead(struct rb_thread_sched *sched, rb_thread_t *th) static void thread_sched_to_waiting_common(struct rb_thread_sched *sched, rb_thread_t *th) { - RUBY_DEBUG_LOG("dedicated:%d", th->nt->dedicated); - thread_sched_to_waiting_common0(sched, th, false); + RUBY_DEBUG_LOG("th:%u DNT:%d", rb_th_serial(th), th->nt->dedicated); + + RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED, th); + + native_thread_dedicated_inc(th->vm, th->ractor, th->nt); + thread_sched_wakeup_next_thread(sched, th, false); } // running -> waiting |
