From ee95372a223b28b7f7c480a9bdfa5f330ad6b49d Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 17 Jul 2025 12:13:20 +0900 Subject: [PATCH] use `Ractor.shareable_proc` `Ractor.make_shareable(a_proc)` will not be supported and we should use `Ractor.shareable_proc` instead. --- lib/ostruct.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 87bbfd3..44dbb0c 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -233,7 +233,10 @@ def marshal_dump # :nodoc: # def new_ostruct_member!(name) # :nodoc: unless @table.key?(name) || is_method_protected!(name) - if defined?(::Ractor) + if defined?(::Ractor.shareable_proc) + getter_proc = Ractor.shareable_proc { @table[name] } + setter_proc = Ractor.shareable_proc {|x| @table[name] = x} + elsif defined?(::Ractor) getter_proc = nil.instance_eval{ Proc.new { @table[name] } } setter_proc = nil.instance_eval{ Proc.new {|x| @table[name] = x} } ::Ractor.make_shareable(getter_proc)