Set Ractor moved object's shape to original object's shape
Fixes [Bug #19409]
This commit is contained in:
parent
e12d4c654e
commit
32c4b0125f
@ -1087,6 +1087,27 @@ assert_equal '333', %q{
|
|||||||
a + b + c + d + e + f
|
a + b + c + d + e + f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# moved objects have their shape properly set to original object's shape
|
||||||
|
assert_equal '1234', %q{
|
||||||
|
class Obj
|
||||||
|
attr_accessor :a, :b, :c, :d
|
||||||
|
def initialize
|
||||||
|
@a = 1
|
||||||
|
@b = 2
|
||||||
|
@c = 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
r = Ractor.new do
|
||||||
|
obj = receive
|
||||||
|
obj.d = 4
|
||||||
|
[obj.a, obj.b, obj.c, obj.d]
|
||||||
|
end
|
||||||
|
obj = Obj.new
|
||||||
|
r.send(obj, move: true)
|
||||||
|
values = r.take
|
||||||
|
values.join
|
||||||
|
}
|
||||||
|
|
||||||
# cvar in shareable-objects are not allowed to access from non-main Ractor
|
# cvar in shareable-objects are not allowed to access from non-main Ractor
|
||||||
assert_equal 'can not access class variables from non-main Ractors', %q{
|
assert_equal 'can not access class variables from non-main Ractors', %q{
|
||||||
class C
|
class C
|
||||||
|
4
ractor.c
4
ractor.c
@ -3504,7 +3504,9 @@ move_enter(VALUE obj, struct obj_traverse_replace_data *data)
|
|||||||
return traverse_skip;
|
return traverse_skip;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data->replacement = rb_obj_alloc(RBASIC_CLASS(obj));
|
VALUE moved = rb_obj_alloc(RBASIC_CLASS(obj));
|
||||||
|
rb_shape_set_shape(moved, rb_shape_get_shape(obj));
|
||||||
|
data->replacement = moved;
|
||||||
return traverse_cont;
|
return traverse_cont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user