File tree Expand file tree Collapse file tree 4 files changed +2
-28
lines changed Expand file tree Collapse file tree 4 files changed +2
-28
lines changed Original file line number Diff line number Diff line change @@ -149,15 +149,6 @@ def remaining_capacity
149
149
@max_queue == 0 ? -1 : @executor . getQueue . remainingCapacity
150
150
end
151
151
152
- # This method is deprecated and will be removed soon.
153
- # This method is supost to return the threads status, but Java API doesn't
154
- # provide a way to get the thread status. So we return an empty Array instead.
155
- def status
156
- warn '[DEPRECATED] `status` is deprecated and will be removed soon.'
157
- warn "Calls to `status` return an empty Array. Java ThreadPoolExecutor does not provide thread's status."
158
- [ ]
159
- end
160
-
161
152
# Is the thread pool running?
162
153
#
163
154
# @return [Boolean] `true` when running, `false` when shutting down or shutdown
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ def initialize(opts = {})
89
89
@pool = [ ] # all workers
90
90
@ready = [ ] # used as a stash (most idle worker is at the start)
91
91
@queue = [ ] # used as queue
92
+ # @ready or @queue is empty at all times
92
93
@scheduled_task_count = 0
93
94
@completed_task_count = 0
94
95
@largest_length = 0
@@ -201,6 +202,7 @@ def ns_kill_execution
201
202
# tries to assign task to a worker, tries to get one from @ready or to create new one
202
203
# @return [true, false] if task is assigned to a worker
203
204
def ns_assign_worker ( *args , &task )
205
+ # keep growing if the pool is not at the minimum yet
204
206
worker = ( @ready . pop if @pool . size >= @min_length ) || ns_add_busy_worker
205
207
if worker
206
208
worker << [ task , args ]
Original file line number Diff line number Diff line change 95
95
end
96
96
end
97
97
98
- context '#status' do
99
-
100
- it 'returns an array' do
101
- skip 'not added' unless subject . respond_to? :status
102
- allow ( subject ) . to receive ( :warn )
103
- expect ( subject . status ) . to be_kind_of ( Array )
104
- end
105
- end
106
-
107
98
context '#idletime' do
108
99
109
100
subject { described_class . new ( idletime : 42 ) }
Original file line number Diff line number Diff line change 145
145
end
146
146
end
147
147
148
- context '#status' do
149
-
150
- it 'returns an array' do
151
- skip 'not added' unless subject . respond_to? :status
152
- allow ( subject ) . to receive ( :warn )
153
- expect ( subject . status ) . to be_kind_of ( Array )
154
- end
155
- end
156
-
157
-
158
148
context '#kill' do
159
149
160
150
it 'attempts to kill all in-progress tasks' do
You can’t perform that action at this time.
0 commit comments