class Async::WorkerPool::Worker
A handle to the work being done.
def call(work)
def call(work) promise = Promise.new(work) @work.push(promise) begin return promise.wait ensure promise.cancel end end
def close
def close if thread = @thread @thread = nil thread.kill end end
def initialize
def initialize @work = ::Thread::Queue.new @thread = ::Thread.new(&method(:run)) end
def run
def run while work = @work.pop work.call end end