mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix Ractor.make_shareable
for recursive structures with unfreezable components
Followup to #3823
This commit is contained in:
parent
750e2d9e5e
commit
e25165b3fc
Notes:
git
2020-12-01 09:34:07 +09:00
2 changed files with 12 additions and 1 deletions
|
@ -984,6 +984,17 @@ assert_equal '[false, false]', %q{
|
||||||
[Ractor.shareable?(x), Ractor.shareable?(y)]
|
[Ractor.shareable?(x), Ractor.shareable?(y)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ractor.make_shareable(recursive_objects)
|
||||||
|
assert_equal '[:ok, false, false]', %q{
|
||||||
|
o = Object.new
|
||||||
|
def o.freeze; raise; end
|
||||||
|
y = []
|
||||||
|
x = [y, o].freeze
|
||||||
|
y << x
|
||||||
|
y.freeze
|
||||||
|
[(Ractor.make_shareable(x) rescue :ok), Ractor.shareable?(x), Ractor.shareable?(y)]
|
||||||
|
}
|
||||||
|
|
||||||
# define_method() can invoke different Ractor's proc if the proc is shareable.
|
# define_method() can invoke different Ractor's proc if the proc is shareable.
|
||||||
assert_equal '1', %q{
|
assert_equal '1', %q{
|
||||||
class C
|
class C
|
||||||
|
|
2
ractor.c
2
ractor.c
|
@ -2089,7 +2089,7 @@ rb_ractor_make_shareable(VALUE obj)
|
||||||
{
|
{
|
||||||
rb_obj_traverse(obj,
|
rb_obj_traverse(obj,
|
||||||
make_shareable_check_shareable,
|
make_shareable_check_shareable,
|
||||||
mark_shareable, mark_shareable);
|
null_leave, mark_shareable);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue