diff options
Diffstat (limited to 'thread_sync.c')
-rw-r--r-- | thread_sync.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/thread_sync.c b/thread_sync.c index 3b8c5364a9..deb3858c31 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -264,13 +264,13 @@ do_mutex_lock(VALUE self, int interruptible_p) th->status = THREAD_STOPPED_FOREVER; th->locking_mutex = self; - th->vm->sleeper++; + rb_ractor_sleeper_threads_inc(th->ractor); /* * Carefully! while some contended threads are in native_sleep(), - * vm->sleeper is unstable value. we have to avoid both deadlock + * ractor->sleeper is unstable value. we have to avoid both deadlock * and busy loop. */ - if ((vm_living_thread_num(th->vm) == th->vm->sleeper) && + if ((rb_ractor_living_thread_num(th->ractor) == rb_ractor_sleeper_thread_num(th->ractor)) && !patrol_thread) { timeout = &rel; patrol_thread = th; @@ -289,17 +289,18 @@ do_mutex_lock(VALUE self, int interruptible_p) th->locking_mutex = Qfalse; if (mutex->th && timeout && !RUBY_VM_INTERRUPTED(th->ec)) { - rb_check_deadlock(th->vm); + rb_check_deadlock(th->ractor); } if (th->status == THREAD_STOPPED_FOREVER) { th->status = prev_status; } - th->vm->sleeper--; + rb_ractor_sleeper_threads_dec(th->ractor); if (interruptible_p) { /* release mutex before checking for interrupts...as interrupt checking * code might call rb_raise() */ if (mutex->th == th) mutex->th = 0; + RUBY_VM_CHECK_INTS_BLOCKING(th->ec); /* may release mutex */ if (!mutex->th) { mutex->th = th; |