Skip to content

Commit e9732d1

Browse files
committed
Add deprecation warnings.
1 parent 692c266 commit e9732d1

File tree

8 files changed

+26
-51
lines changed

8 files changed

+26
-51
lines changed

lib/async/condition.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def wait
4242

4343
# @deprecated Replaced by {#waiting?}
4444
def empty?
45+
warn("`Async::Condition#empty?` is deprecated, use `Async::Condition#waiting?` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
46+
4547
@waiting.empty?
4648
end
4749

lib/async/limited_queue.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55

66
# The implementation lives in `queue.rb` but later we may move it here for better autoload/inference.
77
require_relative "queue"
8+
9+
module Async
10+
class LimitedQueue < Queue
11+
class << self
12+
remove_method :new
13+
end
14+
end
15+
end

lib/async/queue.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ def wait
133133
# A queue which limits the number of items that can be enqueued.
134134
# @public Since *Async v1*.
135135
class LimitedQueue < Queue
136+
def self.new(...)
137+
warn("`require 'async/limited_queue'` to use `Async::LimitedQueue`.", uplevel: 1, category: :deprecated) if $VERBOSE
138+
139+
super
140+
end
141+
136142
# Create a new limited queue.
137143
#
138144
# @parameter limit [Integer] The maximum number of items that can be enqueued.

lib/async/reactor.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module Async
1212
class Reactor < Scheduler
1313
# @deprecated Replaced by {Kernel::Async}.
1414
def self.run(...)
15+
warn("`Async::Reactor.run{}` is deprecated, use `Async{}` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
16+
1517
Async(...)
1618
end
1719

lib/async/scheduler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def run(...)
583583
# @yields {|task| ...} Executed within the task.
584584
# @returns [Task] The task that was scheduled into the reactor.
585585
def async(*arguments, **options, &block)
586-
# warn "Async::Scheduler#async is deprecated. Use `run` or `Task#async` instead.", uplevel: 1, category: :deprecated
586+
warn("Async::Scheduler#async is deprecated. Use `run` or `Task#async` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
587587

588588
Kernel.raise ClosedError if @selector.nil?
589589

lib/async/task.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def initialize(message = "Cannot create child task within a task that has finish
6565

6666
# @deprecated With no replacement.
6767
def self.yield
68+
warn("`Async::Task.yield` is deprecated with no replacement.", uplevel: 1, category: :deprecated) if $VERBOSE
69+
6870
Fiber.scheduler.transfer
6971
end
7072

@@ -134,6 +136,8 @@ def to_s
134136

135137
# @deprecated Prefer {Kernel#sleep} except when compatibility with `stable-v1` is required.
136138
def sleep(duration = nil)
139+
warn("`Async::Task#sleep` is deprecated, use `Kernel#sleep` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
140+
137141
super
138142
end
139143

lib/async/waiter.md

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

lib/async/waiter.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66

77
module Async
88
# A composable synchronization primitive, which allows one task to wait for a number of other tasks to complete. It can be used in conjunction with {Semaphore} and/or {Barrier}.
9+
# @deprecated `Async::Waiter` is deprecated, use `Async::Barrier` instead.
910
class Waiter
1011
# Create a waiter instance.
1112
#
1213
# @parameter parent [Interface(:async) | Nil] The parent task to use for asynchronous operations.
1314
# @parameter finished [Async::Condition] The condition to signal when a task completes.
1415
def initialize(parent: nil, finished: Async::Condition.new)
16+
warn("`Async::Waiter` is deprecated, use `Async::Barrier` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
17+
1518
@finished = finished
1619
@done = []
1720

0 commit comments

Comments
 (0)