File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -44,24 +44,24 @@ module Concurrent
4444 context 'GC' do
4545 it 'does not leave values behind when bind is used' do
4646 var = ThreadLocalVar . new ( 0 )
47- 100 . times . map do |i |
47+ 10 . times . map do |i |
4848 Thread . new { var . bind ( i ) { var . value } }
4949 end . each ( &:join )
5050 var . value = 0
5151 expect ( var . instance_variable_get ( :@storage ) . keys . size ) . to be == 1
5252 end
5353
5454 it 'does not leave values behind when bind is not used' do
55- var = ThreadLocalVar . new ( 0 )
56- 100 . times . map do | i |
57- Thread . new { var . value = i ; var . value }
58- end . each ( & :join )
59- var . value = 0
60- sleep 0.1
61- GC . start
62- sleep 0. 1
63- GC . start
64- expect ( var . instance_variable_get ( :@storage ) . keys . size ) . to be == 1
55+ tries = Array . new ( 10 ) do
56+ var = ThreadLocalVar . new ( 0 )
57+ 10 . times . map do | i |
58+ Thread . new { var . value = i ; var . value }
59+ end . each ( & :join )
60+ var . value = 0
61+ GC . start
62+ var . instance_variable_get ( :@storage ) . keys . size == 1
63+ end
64+ expect ( tries . any? ) . to be_truthy
6565 end
6666 end
6767 end
You can’t perform that action at this time.
0 commit comments