mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
Ractor.shareable_proc(&pr) should copy pr
`pr` should not change on this method.
This commit is contained in:
parent
d105709f2b
commit
02cddcc2be
Notes:
git
2025-12-05 01:45:31 +00:00
@ -157,6 +157,16 @@ assert_equal '[:a, :b, :c, :d, :e]', %q{
|
||||
Ractor.shareable_proc(&closure).call
|
||||
}
|
||||
|
||||
# Ractor.make_shareable makes a copy of given Proc
|
||||
assert_equal '[true, true]', %q{
|
||||
pr1 = Proc.new do
|
||||
self
|
||||
end
|
||||
pr2 = Ractor.shareable_proc(&pr1)
|
||||
|
||||
[pr1.call == self, pr2.call == nil]
|
||||
}
|
||||
|
||||
# Ractor::IsolationError cases
|
||||
assert_equal '3', %q{
|
||||
ok = 0
|
||||
|
||||
2
ractor.c
2
ractor.c
@ -2376,7 +2376,7 @@ ractor_shareable_proc(rb_execution_context_t *ec, VALUE replace_self, bool is_la
|
||||
}
|
||||
else {
|
||||
VALUE proc = is_lambda ? rb_block_lambda() : rb_block_proc();
|
||||
return rb_proc_ractor_make_shareable(proc, replace_self);
|
||||
return rb_proc_ractor_make_shareable(rb_proc_dup(proc), replace_self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user