Skip to content

Commit 6488ad9

Browse files
committed
Deprecation is now in the Concern module.
1 parent 41aa337 commit 6488ad9

File tree

11 files changed

+44
-40
lines changed

11 files changed

+44
-40
lines changed

lib/concurrent/agent.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'concurrent/observable'
44
require 'concurrent/logging'
55
require 'concurrent/executor/executor'
6-
require 'concurrent/utility/deprecation'
6+
require 'concurrent/concern/deprecation'
77

88
module Concurrent
99

@@ -82,7 +82,7 @@ class Agent
8282
include Concern::Dereferenceable
8383
include Observable
8484
include Logging
85-
include Deprecation
85+
include Concern::Deprecation
8686

8787
attr_reader :timeout, :io_executor, :fast_executor
8888

lib/concurrent/atomic/condition.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'concurrent/utility/monotonic_time'
2-
require 'concurrent/utility/deprecation'
2+
require 'concurrent/concern/deprecation'
33

44
module Concurrent
55

@@ -15,7 +15,7 @@ module Concurrent
1515
#
1616
# @deprecated
1717
class Condition
18-
include Deprecation
18+
include Concern::Deprecation
1919

2020
class Result
2121
def initialize(remaining_time)

lib/concurrent/concern/deprecation.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'concurrent/logging'
2+
3+
module Concurrent
4+
module Concern
5+
6+
module Deprecation
7+
# TODO require additional parameter: a version. Display when it'll be removed based on that. Error if not removed.
8+
include Logging
9+
10+
def deprecated(message, strip = 2)
11+
caller_line = caller(strip).first
12+
klass = if Class === self
13+
self
14+
else
15+
self.class
16+
end
17+
log WARN, klass.to_s, format("[DEPRECATED] %s\ncalled on: %s", message, caller_line)
18+
end
19+
20+
def deprecated_method(old_name, new_name)
21+
deprecated "`#{old_name}` is deprecated and it'll removed in next release, use `#{new_name}` instead", 3
22+
end
23+
end
24+
end
25+
end

lib/concurrent/configuration.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
require 'concurrent/executors'
55
require 'concurrent/utility/at_exit'
66
require 'concurrent/utility/processor_counter'
7-
require 'concurrent/utility/deprecation'
7+
require 'concurrent/concern/deprecation'
88

99
module Concurrent
1010
extend Logging
11-
extend Deprecation
11+
extend Concern::Deprecation
1212

1313
# Suppresses all output when used for logging.
1414
NULL_LOGGER = lambda { |level, progname, message = nil, &block| }
@@ -140,7 +140,7 @@ def self.new_io_executor(opts = {})
140140

141141
# A gem-level configuration object.
142142
class Configuration
143-
include Deprecation
143+
include Concern::Deprecation
144144

145145
# Create a new configuration object.
146146
def initialize
@@ -149,7 +149,6 @@ def initialize
149149
# if assigned to {#logger}, it will log nothing.
150150
# @deprecated Use Concurrent::NULL_LOGGER instead
151151
def no_logger
152-
warn '[DEPRECATED] Use Concurrent::NULL_LOGGER instead'
153152
deprecated_method 'Concurrent.configuration.no_logger', 'Concurrent::NULL_LOGGER'
154153
NULL_LOGGER
155154
end

lib/concurrent/executor/executor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require 'concurrent/executor/executor_service'
2-
require 'concurrent/utility/deprecation'
2+
require 'concurrent/concern/deprecation'
33

44
module Concurrent
55

66
module Executor
7-
extend Deprecation
7+
extend Concern::Deprecation
88

99
# Get the requested `Executor` based on the values set in the options hash.
1010
#

lib/concurrent/executor/executor_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
require 'concurrent/atomic/event'
44
require 'concurrent/synchronization'
55
require 'concurrent/utility/at_exit'
6-
require 'concurrent/utility/deprecation'
6+
require 'concurrent/concern/deprecation'
77

88
module Concurrent
99

1010
module ExecutorService
1111
include Logging
12-
include Deprecation
12+
include Concern::Deprecation
1313

1414
# @!macro [attach] executor_service_method_post
1515
#

lib/concurrent/executor/timer_set.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'concurrent/scheduled_task'
22
require 'concurrent/atomic/event'
33
require 'concurrent/collection/priority_queue'
4+
require 'concurrent/concern/deprecation'
45
require 'concurrent/executor/executor_service'
56
require 'concurrent/executor/single_thread_executor'
67

@@ -15,7 +16,7 @@ module Concurrent
1516
#
1617
# @!macro monotonic_clock_warning
1718
class TimerSet < RubyExecutorService
18-
extend Deprecation
19+
extend Concern::Deprecation
1920

2021
# Create a new set of timed tasks.
2122
#

lib/concurrent/obligation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
require 'concurrent/concern/dereferenceable'
55
require 'concurrent/atomic/event'
6-
require 'concurrent/utility/deprecation'
6+
require 'concurrent/concern/deprecation'
77

88
module Concurrent
99

1010
module Obligation
1111
include Concern::Dereferenceable
12-
include Deprecation
12+
include Concern::Deprecation
1313

1414
# Has the obligation been fulfilled?
1515
#

lib/concurrent/utility/deprecation.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/concurrent/utility/timeout.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
require 'thread'
33

44
require 'concurrent/errors'
5-
require 'concurrent/utility/deprecation'
5+
require 'concurrent/concern/deprecation'
66

77
module Concurrent
8+
extend Concern::Deprecation
89

910
# [DEPRECATED] Wait the given number of seconds for the block operation to complete.
1011
# Intended to be a simpler and more reliable replacement to the Ruby

0 commit comments

Comments
 (0)