lib/async/notification.rb in async-1.32.1 vs lib/async/notification.rb in async-2.0.0
- old
+ new
@@ -22,17 +22,17 @@
require_relative 'condition'
module Async
# A synchronization primitive, which allows fibers to wait until a notification is received. Does not block the task which signals the notification. Waiting tasks are resumed on next iteration of the reactor.
+ # @public Since `stable-v1`.
class Notification < Condition
# Signal to a given task that it should resume operations.
- # @return [void]
def signal(value = nil, task: Task.current)
return if @waiting.empty?
- task.reactor << Signal.new(@waiting, value)
+ Fiber.scheduler.push Signal.new(@waiting, value)
@waiting = []
return nil
end
@@ -40,12 +40,12 @@
Signal = Struct.new(:waiting, :value) do
def alive?
true
end
- def resume
+ def transfer
waiting.each do |fiber|
- fiber.resume(value) if fiber.alive?
+ fiber.transfer(value) if fiber.alive?
end
end
end
end
end