diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-12-02 03:37:56 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-12-07 08:28:36 +0900 |
commit | b67b24d0f5e78481e6a306881b6858f0dec996ba (patch) | |
tree | 178f1e37077ded7eb9bae6d2d2031a22a98f43f0 /ractor.c | |
parent | 60eabb1aa7d1d8ab83c49916bd8c3536daf5d03b (diff) |
ruby_single_main_ractor for single ractor mode
ruby_multi_ractor was a flag that indicates the interpreter doesn't
make any additional ractors (single ractor mode).
Instead of boolean flag, ruby_single_main_ractor pointer is introduced
which keeps main ractor's pointer if single ractor mode. If additional
ractors are created, ruby_single_main_ractor becomes NULL.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3842
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -30,8 +30,10 @@ rb_ractor_error_class(void) } RUBY_SYMBOL_EXPORT_BEGIN + // to share with MJIT -bool ruby_multi_ractor; +rb_ractor_t *ruby_single_main_ractor; + RUBY_SYMBOL_EXPORT_END static void vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *r, const char *file, int line); @@ -1158,9 +1160,9 @@ vm_insert_ractor(rb_vm_t *vm, rb_ractor_t *r) else { vm_ractor_blocking_cnt_inc(vm, r, __FILE__, __LINE__); - RUBY_DEBUG_LOG("ruby_multi_ractor=true", 0); // enable multi-ractor mode - ruby_multi_ractor = true; + RUBY_DEBUG_LOG("enable multi-ractor mode", 0); + ruby_single_main_ractor = NULL; if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL)) { rb_warn("Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues."); @@ -1217,6 +1219,7 @@ rb_ractor_main_alloc(void) r->id = ++ractor_last_id; r->loc = Qnil; r->name = Qnil; + ruby_single_main_ractor = r; return r; } |