1 # -*- encoding: binary -*-
5 # Thread pool class based on pulling off a single Ruby Queue.
6 # This is NOT used for the ThreadPool class, since that class does not
7 # need a userspace Queue.
8 class Rainbows::QueuePool < Struct.new(:queue, :threads)
9 def initialize(size = 20, &block)
11 self.threads = (1..size).map do
22 threads.each { |_| queue << nil }
23 threads.delete_if do |t|
25 t.alive? ? t.join(0.01) : true
26 end until threads.empty?