@@ -29,15 +29,6 @@ class RubyThreadPoolExecutor < RubyExecutorService
29
29
# @!macro thread_pool_executor_attr_reader_min_length
30
30
attr_reader :min_length
31
31
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
-
41
32
# @!macro thread_pool_executor_attr_reader_idletime
42
33
attr_reader :idletime
43
34
@@ -49,6 +40,21 @@ def initialize(opts = {})
49
40
super ( opts )
50
41
end
51
42
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
+
52
58
# @!macro executor_service_method_can_overflow_question
53
59
def can_overflow?
54
60
synchronize { ns_limited_queue? }
@@ -174,6 +180,7 @@ def ns_assign_worker(*args, &task)
174
180
worker = ( @ready . pop if @pool . size >= @min_length ) || ns_add_busy_worker
175
181
if worker
176
182
worker << [ task , args ]
183
+ @completed_task_count += 1
177
184
true
178
185
else
179
186
false
@@ -219,8 +226,7 @@ def ns_add_busy_worker
219
226
#
220
227
# @!visibility private
221
228
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
224
230
if task_and_args
225
231
worker << task_and_args
226
232
else
0 commit comments