Class: Henitai::ParallelExecutionRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/henitai/parallel_execution_runner.rb

Overview

Runs pending mutants across worker threads with signal and stdin handling.

Defined Under Namespace

Classes: ParallelExecutionContext

Instance Method Summary collapse

Constructor Details

#initialize(worker_count:) ⇒ ParallelExecutionRunner

Returns a new instance of ParallelExecutionRunner.



11
12
13
# File 'lib/henitai/parallel_execution_runner.rb', line 11

def initialize(worker_count:)
  @worker_count = worker_count
end

Instance Method Details

#execute_parallel_execution(context, stdin_pipe:, process_mutant:) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/henitai/parallel_execution_runner.rb', line 29

def execute_parallel_execution(context, stdin_pipe:, process_mutant:)
  install_parallel_signal_traps(context)
  start_parallel_stdin_watcher(context, stdin_pipe)
  parallel_workers(context, process_mutant).each(&:join)
ensure
  stop_parallel_stdin_watcher(context)
  restore_parallel_signal_traps(context)
  raise context.state[:error] if context&.state&.fetch(:error, nil)
  raise Interrupt if context&.state&.fetch(:stopping, false)
end

#run(mutants, integration, config, progress_reporter, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/henitai/parallel_execution_runner.rb', line 15

def run(mutants, integration, config, progress_reporter, options = {})
  context = build_parallel_context(
    mutants,
    integration,
    config,
    progress_reporter
  )
  execute_parallel_execution(
    context,
    stdin_pipe: options.fetch(:stdin_pipe, false),
    process_mutant: options.fetch(:process_mutant)
  )
end