diff options
author | Koichi Sasada <[email protected]> | 2024-11-05 04:54:06 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2024-11-08 18:02:46 +0900 |
commit | aa63699d10e489bc6d9c13406fc47f581001568b (patch) | |
tree | c01cefb86da657d39e3a8f50771cb84827d5b003 /vm.c | |
parent | 075a102c937969c62a6798b32b3c3188df91a075 (diff) |
support `require` in non-main Ractors
Many libraries should be loaded on the main ractor because of
setting constants with unshareable objects and so on.
This patch allows to call `requore` on non-main Ractors by
asking the main ractor to call `require` on it. The calling ractor
waits for the result of `require` from the main ractor.
If the `require` call failed with some reasons, an exception
objects will be deliverred from the main ractor to the calling ractor
if it is copy-able.
Same on `require_relative` and `require` by `autoload`.
Now `Ractor.new{pp obj}` works well (the first call of `pp` requires
`pp` library implicitly).
[Feature #20627]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11142
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -556,7 +556,7 @@ RB_THREAD_LOCAL_SPECIFIER rb_execution_context_t *ruby_current_ec; RB_THREAD_LOCAL_SPECIFIER rb_atomic_t ruby_nt_serial; #endif -// no-inline decl on thread_pthread.h +// no-inline decl on vm_core.h rb_execution_context_t * rb_current_ec_noinline(void) { @@ -580,6 +580,14 @@ rb_current_ec(void) #endif #else native_tls_key_t ruby_current_ec_key; + +// no-inline decl on vm_core.h +rb_execution_context_t * +rb_current_ec_noinline(void) +{ + return native_tls_get(ruby_current_ec_key); +} + #endif rb_event_flag_t ruby_vm_event_flags; |