class Async::Reactor
def self.run(*args, &block)
the block as an asynchronous task. Will block until the reactor finishes
- When invoked at the top level, will create and run a reactor, and invoke
asynchronously. Will return the task once it has been scheduled.
- When invoked within an existing reactor task, it will run the given block
The preferred method to invoke asynchronous behavior at the top level.
def self.run(*args, &block) if current = Task.current? reactor = current.reactor reactor.async(*args, &block) else reactor = self.new begin reactor.run(*args, &block) ensure reactor.close end return reactor end end