class Async::WorkerPool

@private
A simple work pool that offloads work to a background thread.

def call(work)

@parameter work [Proc] The work to be done.

Offload work to a thread.
def call(work)
	if ready = @ready
		worker = ready.pop
		
		begin
			worker.call(work)
		ensure
			ready.push(worker)
		end
	else
		raise RuntimeError, "No worker available!"
	end
end

def close

Close the work pool. Kills all outstanding work.
def close
	if ready = @ready
		@ready = nil
		ready.close
		
		while worker = ready.pop
			worker.close
		end
	end
end

def initialize(size: Etc.nprocessors)

@parameter size [Integer] The number of threads to use.

Create a new work pool.
def initialize(size: Etc.nprocessors)
	@ready = ::Thread::Queue.new
	
	size.times do
		@ready.push(Worker.new)
	end
end