Skip to content

Commit c541df4

Browse files
Move completed_task_count incrementer after task is successful
Completed task count was previously incremented no matter the success of the task. In hopes to introduce a failed_task_count counter, this moves the increment of the completed_task_count to the block where the thread execution takes place
1 parent 9c5b03a commit c541df4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/concurrent/executor/ruby_thread_pool_executor.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def worker_died(worker)
101101
synchronize { ns_worker_died worker }
102102
end
103103

104+
# @!visibility private
105+
def worker_task_completed
106+
@completed_task_count += 1
107+
end
108+
104109
private
105110

106111
# @!visibility private
@@ -180,7 +185,6 @@ def ns_assign_worker(*args, &task)
180185
worker = (@ready.pop if @pool.size >= @min_length) || ns_add_busy_worker
181186
if worker
182187
worker << [task, args]
183-
@completed_task_count += 1
184188
true
185189
else
186190
false
@@ -327,6 +331,7 @@ def create_worker(queue, pool, idletime)
327331

328332
def run_task(pool, task, args)
329333
task.call(*args)
334+
pool.worker_task_completed
330335
rescue => ex
331336
# let it fail
332337
log DEBUG, ex

0 commit comments

Comments
 (0)