mirror of
https://github.com/ruby/ruby.git
synced 2026-11-09 08:42:18 +08:00
Previously Ractor.new isolated the given block Proc in place (rb_proc_isolate_bang) when the ractor's thread was set up. This mutated the caller's Proc, and rejected every outer variable access. Now Ractor.new duplicates the block and makes the copy shareable exactly as Ractor.shareable_proc does, before any ractor resources are allocated. The block may read outer variables that are never reassigned and refer to shareable objects; writes, reassigned variables, unshareable values and yield still raise Ractor::IsolationError. The original Proc is left unchanged (not frozen, not shareable), and instance variables on it no longer prevent use, as the copy does not carry them. Procs without an iseq (e.g. method procs) keep using rb_proc_isolate. Tests and docs are updated accordingly.