File tree Expand file tree Collapse file tree 2 files changed +27
-12
lines changed
Expand file tree Collapse file tree 2 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,33 @@ module Concurrent
2222
2323 it_should_behave_like :thread_pool_executor
2424
25+ context '#remaining_capacity' do
26+
27+ let! ( :expected_max ) { 100 }
28+
29+ subject do
30+ RubyThreadPoolExecutor . new (
31+ min_threads : 10 ,
32+ max_threads : 20 ,
33+ idletime : 60 ,
34+ max_queue : expected_max ,
35+ overflow_policy : :discard
36+ )
37+ end
38+
39+ it 'returns :max_length when no tasks are enqueued' do
40+ 5 . times { subject . post { nil } }
41+ sleep ( 0.1 )
42+ subject . remaining_capacity . should eq expected_max
43+ end
44+
45+ it 'returns the remaining capacity when tasks are enqueued' do
46+ 100 . times { subject . post { sleep ( 0.5 ) } }
47+ sleep ( 0.1 )
48+ subject . remaining_capacity . should < expected_max
49+ end
50+ end
51+
2552 context '#overload_policy' do
2653
2754 let! ( :min_threads ) { 1 }
Original file line number Diff line number Diff line change 144144 subject . remaining_capacity . should eq expected_max
145145 end
146146
147- it 'returns :max_length when no tasks are enqueued' do
148- 5 . times { subject . post { nil } }
149- sleep ( 0.1 )
150- subject . remaining_capacity . should eq eq expected_max
151- end
152-
153- it 'returns the remaining capacity when tasks are enqueued' do
154- pending ( 'intermittently failing' )
155- 100 . times { subject . post { sleep ( 0.5 ) } }
156- subject . remaining_capacity . should < expected_max
157- end
158-
159147 it 'returns :max_length when stopped' do
160148 100 . times { subject . post { sleep ( 0.5 ) } }
161149 sleep ( 0.1 )
You can’t perform that action at this time.
0 commit comments