44require 'concurrent/at_exit'
55require 'concurrent/executors'
66require 'concurrent/utility/processor_count'
7+ require 'concurrent/utility/deprecation'
78
89module Concurrent
910 extend Logging
11+ extend Deprecation
1012
1113 # Suppresses all output when used for logging.
1214 NULL_LOGGER = lambda { |level , progname , message = nil , &block | }
13- private_constant :NULL_LOGGER
1415
1516 # @!visibility private
1617 GLOBAL_LOGGER = AtomicReference . new ( NULL_LOGGER )
@@ -60,21 +61,21 @@ def self.disable_at_exit_hooks!
6061 end
6162
6263 def self . disable_executor_auto_termination!
63- warn '[DEPRECATED] Use Concurrent. disable_at_exit_hooks! instead '
64+ deprecated_method 'disable_executor_auto_termination!' , ' disable_at_exit_hooks!'
6465 disable_at_exit_hooks!
6566 end
6667
6768 # @return [true,false]
6869 # @see .disable_executor_auto_termination!
6970 def self . disable_executor_auto_termination?
70- warn '[DEPRECATED] Use Concurrent::AtExit.enabled? instead '
71+ deprecated_method 'disable_executor_auto_termination?' , ' Concurrent::AtExit.enabled?'
7172 AtExit . enabled?
7273 end
7374
7475 # terminates all pools and blocks until they are terminated
7576 # @see .disable_executor_auto_termination!
7677 def self . terminate_pools!
77- warn '[DEPRECATED] Use Concurrent::AtExit.run instead '
78+ deprecated_method 'terminate_pools!' , ' Concurrent::AtExit.run'
7879 AtExit . run
7980 end
8081
@@ -139,6 +140,7 @@ def self.new_io_executor(opts = {})
139140
140141 # A gem-level configuration object.
141142 class Configuration
143+ include Deprecation
142144
143145 # Create a new configuration object.
144146 def initialize
@@ -148,6 +150,7 @@ def initialize
148150 # @deprecated Use Concurrent::NULL_LOGGER instead
149151 def no_logger
150152 warn '[DEPRECATED] Use Concurrent::NULL_LOGGER instead'
153+ deprecated_method 'Concurrent.configuration.no_logger' , 'Concurrent::NULL_LOGGER'
151154 NULL_LOGGER
152155 end
153156
@@ -156,7 +159,7 @@ def no_logger
156159 #
157160 # @deprecated Use Concurrent.global_logger instead
158161 def logger
159- warn '[DEPRECATED] Use Concurrent.global_logger instead '
162+ deprecated_method 'Concurrent.configuration.logger' , ' Concurrent.global_logger'
160163 Concurrent . global_logger . value
161164 end
162165
@@ -165,65 +168,65 @@ def logger
165168 #
166169 # @deprecated Use Concurrent.global_logger instead
167170 def logger = ( value )
168- warn '[DEPRECATED] Use Concurrent.global_logger instead '
171+ deprecated_method 'Concurrent.configuration.logger=' , ' Concurrent.global_logger= '
169172 Concurrent . global_logger = value
170173 end
171174
172175 # @deprecated Use Concurrent.global_io_executor instead
173176 def global_task_pool
174- warn '[DEPRECATED] Use Concurrent.global_io_executor instead '
177+ deprecated_method 'Concurrent.configuration.global_task_pool' , ' Concurrent.global_io_executor'
175178 Concurrent . global_io_executor
176179 end
177180
178181 # @deprecated Use Concurrent.global_fast_executor instead
179182 def global_operation_pool
180- warn '[DEPRECATED] Use Concurrent.global_fast_executor instead '
183+ deprecated_method 'Concurrent.configuration.global_operation_pool' , ' Concurrent.global_fast_executor'
181184 Concurrent . global_fast_executor
182185 end
183186
184187 # @deprecated Use Concurrent.global_timer_set instead
185188 def global_timer_set
186- warn '[DEPRECATED] Use Concurrent.global_timer_set instead '
189+ deprecated_method ' Concurrent.configuration. global_timer_set' , 'Concurrent.global_timer_set '
187190 Concurrent . global_timer_set
188191 end
189192
190193 # @deprecated Replacing global thread pools is deprecated.
191194 # Use the :executor constructor option instead.
192195 def global_task_pool = ( executor )
193- warn '[DEPRECATED] Replacing global thread pools is deprecated. Use the :executor constructor option instead.'
196+ deprecated ' Replacing global thread pools is deprecated. Use the :executor constructor option instead.'
194197 GLOBAL_IO_EXECUTOR . reconfigure { executor } or
195198 raise ConfigurationError . new ( 'global task pool was already set' )
196199 end
197200
198201 # @deprecated Replacing global thread pools is deprecated.
199202 # Use the :executor constructor option instead.
200203 def global_operation_pool = ( executor )
201- warn '[DEPRECATED] Replacing global thread pools is deprecated. Use the :executor constructor option instead.'
204+ deprecated ' Replacing global thread pools is deprecated. Use the :executor constructor option instead.'
202205 GLOBAL_FAST_EXECUTOR . reconfigure { executor } or
203206 raise ConfigurationError . new ( 'global operation pool was already set' )
204207 end
205208
206209 # @deprecated Use Concurrent.new_io_executor instead
207210 def new_task_pool
208- warn '[DEPRECATED] Use Concurrent.new_io_executor instead '
211+ deprecated_method 'Concurrent.configuration.new_task_pool' , ' Concurrent.new_io_executor'
209212 Concurrent . new_io_executor
210213 end
211214
212215 # @deprecated Use Concurrent.new_fast_executor instead
213216 def new_operation_pool
214- warn '[DEPRECATED] Use Concurrent.new_fast_executor instead '
217+ deprecated_method 'Concurrent.configuration.new_operation_pool' , ' Concurrent.new_fast_executor'
215218 Concurrent . new_fast_executor
216219 end
217220
218221 # @deprecated Use Concurrent.disable_auto_termination_of_global_executors! instead
219222 def auto_terminate = ( value )
220- warn '[DEPRECATED] Use Concurrent.disable_auto_termination_of_global_executors! instead '
223+ deprecated_method 'Concurrent.configuration.auto_terminate=' , ' Concurrent.disable_auto_termination_of_global_executors!'
221224 Concurrent . disable_auto_termination_of_global_executors! if !value
222225 end
223226
224227 # @deprecated Use Concurrent.auto_terminate_global_executors? instead
225228 def auto_terminate
226- warn '[DEPRECATED] Use Concurrent.auto_terminate_global_executors? instead '
229+ deprecated_method 'Concurrent.configuration.auto_terminate' , ' Concurrent.auto_terminate_global_executors?'
227230 Concurrent . auto_terminate_global_executors?
228231 end
229232 end
0 commit comments