class Minitest::ParallelEach

def count # :nodoc:

:nodoc:
def count # :nodoc:
  [@queue.size - N, 0].max
end

def each

def each
  threads = N.times.map {
    Thread.new do
      Thread.current.abort_on_exception = true
      while job = @queue.pop
        yield job
      end
    end
  }
  threads.map(&:join)
end

def initialize list

def initialize list
  @queue = Queue.new # *sigh*... the Queue api sucks sooo much...
  list.each { |i| @queue << i }
  N.times { @queue << nil }
end

def select(&block) # :nodoc:

:nodoc:
def select(&block) # :nodoc:
  self.class.new super
end