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:
Koichi Sasada 2024-11-05 04:54:06 +09:00
parent 075a102c93
commit aa63699d10
Notes: git 2024-11-08 09:03:09 +00:00
10 changed files with 388 additions and 24 deletions

View file

@ -132,7 +132,6 @@ struct rb_thread_sched {
#ifdef RB_THREAD_LOCAL_SPECIFIER
NOINLINE(void rb_current_ec_set(struct rb_execution_context_struct *));
NOINLINE(struct rb_execution_context_struct *rb_current_ec_noinline(void));
# ifdef __APPLE__
// on Darwin, TLS can not be accessed across .so