Skip to Content Skip to Search

Thread pool executor using a test distributor strategy. Provides the same interface as Minitest::Parallel::Executor but with configurable distribution (round robin vs work stealing).

Methods
#
N
S

Attributes

[R] size

Class Public methods

new(size:, distributor:)

# File activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb, line 14
def initialize(size:, distributor:)
  @size = size
  @distributor = distributor
  @pool = Concurrent::FixedThreadPool.new(size, fallback_policy: :abort)
end

Instance Public methods

<<(work)

# File activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb, line 26
def <<(work)
  @distributor.add_test(work)
end

shutdown()

# File activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb, line 30
def shutdown
  @distributor.close
  @pool.shutdown
  @pool.wait_for_termination
end

start()

# File activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb, line 20
def start
  size.times do |worker_id|
    @pool.post { worker_loop(worker_id) }
  end
end