mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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]
This commit is contained in:
parent
075a102c93
commit
aa63699d10
Notes:
git
2024-11-08 09:03:09 +00:00
10 changed files with 388 additions and 24 deletions
|
@ -2994,7 +2994,7 @@ rb_autoload_load(VALUE module, ID name)
|
|||
|
||||
// At this point, we assume there might be autoloading, so fail if it's ractor:
|
||||
if (UNLIKELY(!rb_ractor_main_p())) {
|
||||
rb_raise(rb_eRactorUnsafeError, "require by autoload on non-main Ractor is not supported (%s)", rb_id2name(name));
|
||||
return rb_ractor_autoload_load(module, name);
|
||||
}
|
||||
|
||||
// This state is stored on the stack and is used during the autoload process.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue