Skip to content

Commit 722e59d

Browse files
committed
fix tests
1 parent 82b1301 commit 722e59d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

spec/concurrent/executor/ruby_cached_thread_pool_spec.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ module Concurrent
2424
subject{ described_class.new(idletime: 1, max_threads: 2, gc_interval: 0) }
2525

2626
it 'removes from pool any thread that has been idle too long' do
27-
subject.instance_variable_set(:@idletime, 1)
2827
latch = Concurrent::CountDownLatch.new(3)
29-
3.times { subject << proc{ sleep(0.1); latch.count_down } }
28+
4.times { subject << proc { sleep 0.1; latch.count_down } }
3029
expect(latch.wait(1)).to be true
3130

31+
subject.instance_variable_set(:@idletime, 1)
32+
33+
sleep 1.5
34+
3235
max_threads = subject.length
33-
sleep(2)
3436

35-
latch = Concurrent::CountDownLatch.new(1)
36-
subject << proc{ latch.count_down }
37-
expect(latch.wait(1)).to be true
37+
subject.send :prune_pool
38+
sleep 0.1
39+
subject.send :prune_pool
3840

3941
expect(subject.length).to be < max_threads
4042
end

0 commit comments

Comments
 (0)