We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1241953 + 9a15c07 commit 4b70f6eCopy full SHA for 4b70f6e
spec/concurrent/atomic/thread_local_var_spec.rb
@@ -50,6 +50,23 @@ module Concurrent
50
var.value = 0
51
expect(var.instance_variable_get(:@storage).keys.size).to be == 1
52
end
53
+
54
+ it 'does not leave values behind when bind is not used' do
55
+ skip 'GC.run works reliably only on MRI' unless mri? # TODO
56
57
+ result = 7.times.any? do |i|
58
+ var = ThreadLocalVar.new(0)
59
+ 5.times.map { |i| Thread.new { var.value = i; var.value } }.each(&:join)
60
+ var.value = 0
61
+ # TODO find out why long sleep is necessary, does it take longer for threads to be collected?
62
+ sleep 0.1 * 2**i
63
+ GC.start
64
65
+ var.instance_variable_get(:@storage).keys.size == 1
66
+ end
67
68
+ expect(result).to be_truthy
69
70
71
72
0 commit comments