class Async::Reactor
def self.run(*arguments, **options, &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(*arguments, **options, &block) if current = Task.current? reactor = current.reactor return reactor.async(*arguments, **options, &block) else reactor = self.new begin return reactor.run(*arguments, **options, &block) ensure reactor.close end end end