mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Ractor: revert to moving object bytes, but size pool aware
Using `rb_obj_clone` introduce other problems, such as `initialize_*` callbacks invocation in the context of the parent ractor. So we can revert back to copy the content of the object slots, but in a way that is aware of size pools.
This commit is contained in:
parent
eb765913c1
commit
085cc6e434
Notes:
git
2025-04-04 14:26:46 +00:00
5 changed files with 73 additions and 11 deletions
|
@ -2101,3 +2101,24 @@ assert_equal 'ok', %q{
|
|||
:fail
|
||||
end
|
||||
}
|
||||
|
||||
# move objects inside frozen containers
|
||||
assert_equal 'ok', %q{
|
||||
ractor = Ractor.new { Ractor.receive }
|
||||
obj = Array.new(10, 42)
|
||||
original = obj.dup
|
||||
ractor.send([obj].freeze, move: true)
|
||||
roundtripped_obj = ractor.take[0]
|
||||
roundtripped_obj == original ? :ok : roundtripped_obj
|
||||
}
|
||||
|
||||
# move object with generic ivar
|
||||
assert_equal 'ok', %q{
|
||||
ractor = Ractor.new { Ractor.receive }
|
||||
obj = Array.new(10, 42)
|
||||
obj.instance_variable_set(:@array, [1])
|
||||
|
||||
ractor.send(obj, move: true)
|
||||
roundtripped_obj = ractor.take
|
||||
roundtripped_obj.instance_variable_get(:@array) == [1] ? :ok : roundtripped_obj
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue