Class: Minitest::Parallel::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/parallel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ Executor

Returns a new instance of Executor.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

Instance Method Details

#<<(work) ⇒ Object



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

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

#shutdownObject



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

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