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)
11 def initialize(size = 20, &block)
13 self.threads = (1..size).map do
24 threads.each { |_| queue << nil }
25 threads.delete_if do |t|
27 t.alive? ? t.join(0.01) : true
28 end until threads.empty?