Class: Henitai::ProcessWorkerRunner
- Inherits:
-
Object
- Object
- Henitai::ProcessWorkerRunner
- Defined in:
- lib/henitai/process_worker_runner.rb
Overview
Flat, single-threaded process-slot scheduler for parallel mutation runs.
Owns the process table: it is the sole caller of Process.wait* so there are no race conditions between threads reaping the same child.
Defined Under Namespace
Constant Summary collapse
- PROCESS_DRAIN_WINDOW =
rubocop:disable Metrics/ClassLength
0.2
Instance Method Summary collapse
-
#initialize(worker_count:, runtime: Runtime.new, wakeup: nil) ⇒ ProcessWorkerRunner
constructor
A new instance of ProcessWorkerRunner.
-
#request_shutdown ⇒ Object
Trigger a graceful shutdown from outside the event loop.
-
#run(mutants, integration, config, progress_reporter, options = {}) ⇒ Array<ScenarioExecutionResult>
Runs all mutants and returns an array of ScenarioExecutionResult.
Constructor Details
#initialize(worker_count:, runtime: Runtime.new, wakeup: nil) ⇒ ProcessWorkerRunner
Returns a new instance of ProcessWorkerRunner.
41 42 43 44 45 46 |
# File 'lib/henitai/process_worker_runner.rb', line 41 def initialize(worker_count:, runtime: Runtime.new, wakeup: nil) @worker_count = worker_count @runtime = runtime @wakeup = wakeup @shutdown_requested = false end |
Instance Method Details
#request_shutdown ⇒ Object
Trigger a graceful shutdown from outside the event loop. Safe to call from any thread. The loop observes the flag on its next tick.
50 51 52 53 |
# File 'lib/henitai/process_worker_runner.rb', line 50 def request_shutdown @shutdown_requested = true @wakeup&.signal end |
#run(mutants, integration, config, progress_reporter, options = {}) ⇒ Array<ScenarioExecutionResult>
Runs all mutants and returns an array of ScenarioExecutionResult.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/henitai/process_worker_runner.rb', line 63 def run(mutants, integration, config, progress_reporter, = {}) Integration::SchedulerDiagnostics.reset! if Integration::SchedulerDiagnostics.enabled? prepare_run(mutants, integration, config, progress_reporter, ) event_loop @results ensure @wakeup&.close @wakeup = nil end |