diff options
author | Koichi Sasada <ko1@atdot.net> | 2023-03-30 02:50:51 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-03-30 14:56:23 +0900 |
commit | 94e41822679ebd269564ad10d366596e1514d4ef (patch) | |
tree | 0eda5149b52e3e8e038e51a960ab655cf81a2bd9 /ractor.c | |
parent | ba72849a3f5d2369821dfecbb5bf60b9a0e7cd4e (diff) |
`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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7617
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |