@@ -29,15 +29,6 @@ class RubyThreadPoolExecutor < RubyExecutorService
2929 # @!macro thread_pool_executor_attr_reader_min_length
3030 attr_reader :min_length
3131
32- # @!macro thread_pool_executor_attr_reader_largest_length
33- attr_reader :largest_length
34-
35- # @!macro thread_pool_executor_attr_reader_scheduled_task_count
36- attr_reader :scheduled_task_count
37-
38- # @!macro thread_pool_executor_attr_reader_completed_task_count
39- attr_reader :completed_task_count
40-
4132 # @!macro thread_pool_executor_attr_reader_idletime
4233 attr_reader :idletime
4334
@@ -49,6 +40,21 @@ def initialize(opts = {})
4940 super ( opts )
5041 end
5142
43+ # @!macro thread_pool_executor_attr_reader_largest_length
44+ def largest_length
45+ synchronize { @largest_length }
46+ end
47+
48+ # @!macro thread_pool_executor_attr_reader_scheduled_task_count
49+ def scheduled_task_count
50+ synchronize { @scheduled_task_count }
51+ end
52+
53+ # @!macro thread_pool_executor_attr_reader_completed_task_count
54+ def completed_task_count
55+ synchronize { @completed_task_count }
56+ end
57+
5258 # @!macro executor_service_method_can_overflow_question
5359 def can_overflow?
5460 synchronize { ns_limited_queue? }
@@ -174,6 +180,7 @@ def ns_assign_worker(*args, &task)
174180 worker = ( @ready . pop if @pool . size >= @min_length ) || ns_add_busy_worker
175181 if worker
176182 worker << [ task , args ]
183+ @completed_task_count += 1
177184 true
178185 else
179186 false
@@ -219,8 +226,7 @@ def ns_add_busy_worker
219226 #
220227 # @!visibility private
221228 def ns_ready_worker ( worker , success = true )
222- @completed_task_count += 1 if success
223- task_and_args = @queue . shift
229+ task_and_args = @queue . shift
224230 if task_and_args
225231 worker << task_and_args
226232 else
0 commit comments