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 /vm_core.h | |
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 'vm_core.h')
-rw-r--r-- | vm_core.h | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1876,17 +1876,23 @@ rb_current_thread(void) } static inline rb_ractor_t * -rb_current_ractor(void) +rb_current_ractor_raw(bool expect) { if (ruby_single_main_ractor) { return ruby_single_main_ractor; } else { - const rb_execution_context_t *ec = GET_EC(); - return rb_ec_ractor_ptr(ec); + const rb_execution_context_t *ec = rb_current_execution_context(expect); + return (expect || ec) ? rb_ec_ractor_ptr(ec) : NULL; } } +static inline rb_ractor_t * +rb_current_ractor(void) +{ + return rb_current_ractor_raw(true); +} + static inline rb_vm_t * rb_current_vm(void) { |