lib/async/task.rb in async-2.15.3 vs lib/async/task.rb in async-2.16.0

- old
+ new

@@ -65,9 +65,16 @@ # @deprecated With no replacement. def self.yield Fiber.scheduler.transfer end + # Run the given block of code in a task, asynchronously, in the given scheduler. + def self.run(scheduler, *arguments, **options, &block) + self.new(scheduler, **options, &block).tap do |task| + task.run(*arguments) + end + end + # Create a new task. # @parameter reactor [Reactor] the reactor this task will run within. # @parameter parent [Task] the parent task. def initialize(parent = Task.current?, finished: nil, **options, &block) super(parent, **options)