@@ -14,6 +14,154 @@ module Concurrent
1414 end
1515 private_constant :FixedThreadPoolImplementation
1616
17+ # @!macro [new] thread_pool_executor_constant_default_max_pool_size
18+ # Default maximum number of threads that will be created in the pool.
19+
20+ # @!macro [new] thread_pool_executor_constant_default_min_pool_size
21+ # Default minimum number of threads that will be retained in the pool.
22+
23+ # @!macro [new] thread_pool_executor_constant_default_max_queue_size
24+ # Default maximum number of tasks that may be added to the task queue.
25+
26+ # @!macro [new] thread_pool_executor_constant_default_thread_timeout
27+ # Default maximum number of seconds a thread in the pool may remain idle
28+ # before being reclaimed.
29+
30+ # @!macro [new] thread_pool_executor_attr_reader_max_length
31+ # The maximum number of threads that may be created in the pool.
32+ # @return [Integer] The maximum number of threads that may be created in the pool.
33+
34+ # @!macro [new] thread_pool_executor_attr_reader_min_length
35+ # The minimum number of threads that may be retained in the pool.
36+ # @return [Integer] The minimum number of threads that may be retained in the pool.
37+
38+ # @!macro [new] thread_pool_executor_attr_reader_largest_length
39+ # The largest number of threads that have been created in the pool since construction.
40+ # @return [Integer] The largest number of threads that have been created in the pool since construction.
41+
42+ # @!macro [new] thread_pool_executor_attr_reader_scheduled_task_count
43+ # The number of tasks that have been scheduled for execution on the pool since construction.
44+ # @return [Integer] The number of tasks that have been scheduled for execution on the pool since construction.
45+
46+ # @!macro [new] thread_pool_executor_attr_reader_completed_task_count
47+ # The number of tasks that have been completed by the pool since construction.
48+ # @return [Integer] The number of tasks that have been completed by the pool since construction.
49+
50+ # @!macro [new] thread_pool_executor_attr_reader_idletime
51+ # The number of seconds that a thread may be idle before being reclaimed.
52+ # @return [Integer] The number of seconds that a thread may be idle before being reclaimed.
53+
54+ # @!macro [new] thread_pool_executor_attr_reader_max_queue
55+ # The maximum number of tasks that may be waiting in the work queue at any one time.
56+ # When the queue size reaches `max_queue` subsequent tasks will be rejected in
57+ # accordance with the configured `fallback_policy`.
58+ #
59+ # @return [Integer] The maximum number of tasks that may be waiting in the work queue at any one time.
60+ # When the queue size reaches `max_queue` subsequent tasks will be rejected in
61+ # accordance with the configured `fallback_policy`.
62+
63+ # @!macro [new] thread_pool_executor_attr_reader_length
64+ # The number of threads currently in the pool.
65+ # @return [Integer] The number of threads currently in the pool.
66+
67+ # @!macro [new] thread_pool_executor_attr_reader_queue_length
68+ # The number of tasks in the queue awaiting execution.
69+ # @return [Integer] The number of tasks in the queue awaiting execution.
70+
71+ # @!macro [new] thread_pool_executor_attr_reader_remaining_capacity
72+ # Number of tasks that may be enqueued before reaching `max_queue` and rejecting
73+ # new tasks. A value of -1 indicates that the queue may grow without bound.
74+ #
75+ # @return [Integer] Number of tasks that may be enqueued before reaching `max_queue` and rejecting
76+ # new tasks. A value of -1 indicates that the queue may grow without bound.
77+
78+
79+
80+
81+
82+ # @!macro [new] thread_pool_executor_public_api
83+ #
84+ # @!attribute [r] fallback_policy
85+ # @!macro executor_service_attr_reader_fallback_policy
86+ #
87+ # @!attribute [r] max_length
88+ # @!macro thread_pool_executor_attr_reader_max_length
89+ #
90+ # @!attribute [r] min_length
91+ # @!macro thread_pool_executor_attr_reader_min_length
92+ #
93+ # @!attribute [r] largest_length
94+ # @!macro thread_pool_executor_attr_reader_largest_length
95+ #
96+ # @!attribute [r] scheduled_task_count
97+ # @!macro thread_pool_executor_attr_reader_scheduled_task_count
98+ #
99+ # @!attribute [r] completed_task_count
100+ # @!macro thread_pool_executor_attr_reader_completed_task_count
101+ #
102+ # @!attribute [r] idletime
103+ # @!macro thread_pool_executor_attr_reader_idletime
104+ #
105+ # @!attribute [r] max_queue
106+ # @!macro thread_pool_executor_attr_reader_max_queue
107+ #
108+ # @!attribute [r] length
109+ # @!macro thread_pool_executor_attr_reader_length
110+ #
111+ # @!attribute [r] queue_length
112+ # @!macro thread_pool_executor_attr_reader_queue_length
113+ #
114+ # @!attribute [r] remaining_capacity
115+ # @!macro thread_pool_executor_attr_reader_remaining_capacity
116+ #
117+ # @!method can_overflow?
118+ # @!macro executor_service_method_can_overflow_question
119+ #
120+ # @!method shutdown
121+ # @!macro executor_service_method_shutdown
122+ #
123+ # @!method kill
124+ # @!macro executor_service_method_kill
125+ #
126+ # @!method wait_for_termination(timeout = nil)
127+ # @!macro executor_service_method_wait_for_termination
128+ #
129+ # @!method running?
130+ # @!macro executor_service_method_running_question
131+ #
132+ # @!method shuttingdown?
133+ # @!macro executor_service_method_shuttingdown_question
134+ #
135+ # @!method shutdown?
136+ # @!macro executor_service_method_shutdown_question
137+ #
138+ # @!method auto_terminate?
139+ # @!macro executor_service_method_auto_terminate_question
140+ #
141+ # @!method auto_terminate=(value)
142+ # @!macro executor_service_method_auto_terminate_setter
143+
144+
145+
146+
147+
148+ # @!macro [new] fixed_thread_pool_method_initialize
149+ #
150+ # Create a new thread pool.
151+ #
152+ # @param [Integer] num_threads the number of threads to allocate
153+ # @param [Hash] opts the options defining pool behavior.
154+ # @option opts [Symbol] :fallback_policy (`:abort`) the fallback policy
155+ #
156+ # @raise [ArgumentError] if `num_threads` is less than or equal to zero
157+ # @raise [ArgumentError] if `fallback_policy` is not a known policy
158+ #
159+ # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool-int-
160+
161+
162+
163+
164+
17165 # @!macro [attach] fixed_thread_pool
18166 #
19167 # A thread pool with a set number of threads. The number of threads in the pool
@@ -26,6 +174,8 @@ module Concurrent
26174 #
27175 # @!macro [attach] thread_pool_options
28176 #
177+ # **Thread Pool Options**
178+ #
29179 # Thread pools support several configuration options:
30180 #
31181 # * `idletime`: The number of seconds that a thread may be idle before being reclaimed.
@@ -78,6 +228,11 @@ module Concurrent
78228 # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html Java Executors class
79229 # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html Java ExecutorService interface
80230 # @see http://ruby-doc.org//core-2.2.0/Kernel.html#method-i-at_exit Kernel#at_exit
231+ #
232+ # @!macro thread_pool_executor_public_api
81233 class FixedThreadPool < FixedThreadPoolImplementation
234+
235+ # @!method initialize(num_threads, opts = {})
236+ # @!macro fixed_thread_pool_method_initialize
82237 end
83238end
0 commit comments