Skip to content

Commit d9d65dc

Browse files
committed
Add sharing spec for Fiber and Thread -local variables
1 parent 234d5cb commit d9d65dc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/truffle/thread_safe_objects_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,26 @@ def wb; @wb; end
255255
shared?(new_hash).should == true
256256
end
257257

258+
it "Fiber local variables which do not share the value" do
259+
thread = Thread.current
260+
shared?(thread).should == true
261+
262+
obj = Object.new
263+
thread[:sharing_spec] = obj
264+
begin
265+
shared?(obj).should == false
266+
ensure
267+
thread[:sharing_spec] = nil
268+
end
269+
end
270+
271+
it "Thread local variables which share the value (probably they should not)" do
272+
thread = Thread.current
273+
shared?(thread).should == true
274+
275+
obj = Object.new
276+
thread.thread_variable_set(:sharing_spec, obj)
277+
shared?(obj).should == true # current non-ideal behavior
278+
end
279+
258280
end

0 commit comments

Comments
 (0)