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
22
22
23
23
it_should_behave_like :thread_pool_executor
24
24
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
+
25
52
context '#overload_policy' do
26
53
27
54
let! ( :min_threads ) { 1 }
Original file line number Diff line number Diff line change 144
144
subject . remaining_capacity . should eq expected_max
145
145
end
146
146
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
-
159
147
it 'returns :max_length when stopped' do
160
148
100 . times { subject . post { sleep ( 0.5 ) } }
161
149
sleep ( 0.1 )
You can’t perform that action at this time.
0 commit comments