Class: ActiveSupport::Testing::Parallelization::ThreadPoolExecutor
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb |
Overview
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).
Class Method Summary
- .new(size:, distributor:) ⇒ ThreadPoolExecutor constructor
Instance Attribute Summary
- #size readonly
Instance Method Summary
Constructor Details
.new(size:, distributor:) ⇒ ThreadPoolExecutor
Instance Attribute Details
#size (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb', line 12
attr_reader :size
Instance Method Details
#<<(work)
[ GitHub ]# File 'activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb', line 26
def <<(work) @distributor.add_test(work) end
#shutdown
[ GitHub ]# 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
[ GitHub ]# 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
#worker_loop(worker_id) (private)
[ GitHub ]# File 'activesupport/lib/active_support/testing/parallelization/thread_pool_executor.rb', line 37
def worker_loop(worker_id) while job = @distributor.take(worker_id: worker_id) klass, method, reporter = job reporter.synchronize { reporter.prerecord klass, method } result = Minitest.run_one_method klass, method reporter.synchronize { reporter.record result } end end