123456789_123456789_123456789_123456789_123456789_

Class: Minitest::Parallel::Executor

Relationships & Source Files
Inherits: Object
Defined in: lib/minitest/parallel.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(size) ⇒ Executor

[ GitHub ]

  
# File 'lib/minitest/parallel.rb', line 6

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

Instance Attribute Details

#size (readonly)

[ GitHub ]

  
# File 'lib/minitest/parallel.rb', line 4

attr_reader :size

Instance Method Details

#<<(work)

[ GitHub ]

  
# File 'lib/minitest/parallel.rb', line 21

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

#shutdown

[ GitHub ]

  
# File 'lib/minitest/parallel.rb', line 23

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