class Minitest::Parallel::Executor

def << work; @queue << work; end

def << work; @queue << work; end

def initialize size

def initialize size
  @size  = size
  @queue = Thread::Queue.new
  @pool  = nil
end

def shutdown

def shutdown
  size.times { @queue << nil }
  @pool.each(&:join)
end

def start

def start
  @pool  = Array.new(size) {
    Thread.new @queue do |queue|
      Thread.current.abort_on_exception = true
      while job = queue.pop do
        klass, method, reporter = job
        reporter.synchronize { reporter.prerecord klass, method }
        result = Minitest.run_one_method klass, method
        reporter.synchronize { reporter.record result }
      end
    end
  }
end