Class: Minitest::Parallel::Executor (Ruby 2.7.5)
Description: Class : Minitest::Parallel::Executor - Ruby 2.7.5

### Home Classes Methods

### In Files

- minitest-5.13.0/lib/minitest/parallel.rb

### Parent

Object

### Methods

- ::new
- #<<
- #shutdown
- #start

### Files

- History.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Kernel
- Minitest::AbstractReporter
- Minitest::Assertion
- Minitest::Assertions
- Minitest::BacktraceFilter
- Minitest::BenchSpec
- Minitest::Benchmark
- Minitest::CompositeReporter
- Minitest::Expectations
- Minitest::Guard
- Minitest::Mock
- Minitest::Parallel
- Minitest::Parallel::Executor
- Minitest::PrideIO
- Minitest::PrideLOL
- Minitest::ProgressReporter
- Minitest::Reportable
- Minitest::Result
- Minitest::Skip
- Minitest::Spec
- Minitest::Spec::DSL
- Minitest::Spec::DSL::InstanceMethods
- Minitest::StatisticsReporter
- Minitest::SummaryReporter
- Minitest::Test
- Minitest::Test::LifecycleHooks
- Minitest::UnexpectedError
- Object
- SubThingySpec
- ThingySpec

No matching classes.

# Minitest::Parallel::Executor

The engine used to run multiple tests in parallel.

### Attributes

size[R]

The size of the pool of workers.

### Public Class Methods

new(size) click to toggle source

Create a parallel test executor of with `size` workers.

                   # File minitest-5.13.0/lib/minitest/parallel.rb, line 17
    def initialize size
      @size  = size
      @queue = Queue.new
      @pool  = nil
    end

### Public Instance Methods

<<(work;) click to toggle source

Add a job to the queue

                   # File minitest-5.13.0/lib/minitest/parallel.rb, line 43
    def << work; @queue << work; end

shutdown() click to toggle source

Shuts down the pool of workers by signalling them to quit and waiting for them all to finish what they're currently working on.

                   # File minitest-5.13.0/lib/minitest/parallel.rb, line 50
    def shutdown
      size.times { @queue << nil }
      @pool.each(&:join)
    end

start() click to toggle source

Start the executor

                   # File minitest-5.13.0/lib/minitest/parallel.rb, line 26
    def start
      @pool  = size.times.map {
        Thread.new(@queue) do |queue|
          Thread.current.abort_on_exception = true
          while (job = queue.pop)
            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