summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2023-03-30 02:50:51 +0900
committerKoichi Sasada <ko1@atdot.net>2023-03-30 14:56:23 +0900
commit94e41822679ebd269564ad10d366596e1514d4ef (patch)
tree0eda5149b52e3e8e038e51a960ab655cf81a2bd9 /ractor.c
parentba72849a3f5d2369821dfecbb5bf60b9a0e7cd4e (diff)
downloadruby-94e41822679ebd269564ad10d366596e1514d4ef.tar.gz
`rb_current_ractor_raw(b)`
`rb_current_ractor()` expects it has valid `ec` and `r`. `rb_current_ractor_raw()` with a parameter `false` allows to return NULL if `ec` is not available.
Diffstat (limited to 'ractor.c')
-rw-r--r--ractor.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ractor.c b/ractor.c
index b56f020586..23b3ca98f3 100644
--- a/ractor.c
+++ b/ractor.c
@@ -61,18 +61,19 @@ ASSERT_ractor_locking(rb_ractor_t *r)
static void
ractor_lock(rb_ractor_t *r, const char *file, int line)
{
- RUBY_DEBUG_LOG2(file, line, "locking r:%u%s", r->pub.id, GET_RACTOR() == r ? " (self)" : "");
+ RUBY_DEBUG_LOG2(file, line, "locking r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
ASSERT_ractor_unlocking(r);
rb_native_mutex_lock(&r->sync.lock);
#if RACTOR_CHECK_MODE > 0
if (rb_current_execution_context(false) != NULL) { // GET_EC is NULL in an RJIT worker
- r->sync.locked_by = rb_ractor_self(GET_RACTOR());
+ rb_ractor_t *cr = rb_current_ractor_raw(false);
+ r->sync.locked_by = cr ? rb_ractor_self(cr) : Qundef;
}
#endif
- RUBY_DEBUG_LOG2(file, line, "locked r:%u%s", r->pub.id, GET_RACTOR() == r ? " (self)" : "");
+ RUBY_DEBUG_LOG2(file, line, "locked r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
}
static void
@@ -94,7 +95,7 @@ ractor_unlock(rb_ractor_t *r, const char *file, int line)
#endif
rb_native_mutex_unlock(&r->sync.lock);
- RUBY_DEBUG_LOG2(file, line, "r:%u%s", r->pub.id, GET_RACTOR() == r ? " (self)" : "");
+ RUBY_DEBUG_LOG2(file, line, "r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
}
static void