class Async::Container::Threaded
Manages a reactor within one or more threads.
def initialize(concurrency: 1, &block)
def initialize(concurrency: 1, &block) @reactors = concurrency.times.collect do Async::Reactor.new end @threads = @reactors.collect do |reactor| Thread.new do Thread.current.abort_on_exception = true begin reactor.run(&block) rescue Interrupt # Exit cleanly. end end end end
def stop
def stop @reactors.each(&:stop) @threads.each(&:join) end