Class: Henitai::ProcessWorkerRunner
- Inherits:
-
Object
- Object
- Henitai::ProcessWorkerRunner
- Defined in:
- lib/henitai/process_worker_runner.rb
Overview
Flat, single-threaded driver for parallel mutation runs.
Owns the event loop and OS signal handling, and delegates the slot lifecycle (spawning, reaping, timeout detection and the drain/broadcast state machine) to a SlotScheduler. Because the scheduler is the sole caller of Process.wait*, there are no races between threads reaping the same child.
Defined Under Namespace
Classes: Runtime
Instance Attribute Summary collapse
-
#runtime ⇒ Object
readonly
Loop primitives the SlotScheduler reads back from its host.
-
#wakeup ⇒ Object
readonly
Loop primitives the SlotScheduler reads back from its host.
-
#worker_count ⇒ Object
readonly
Loop primitives the SlotScheduler reads back from its host.
Instance Method Summary collapse
-
#flaky_retry_count ⇒ Object
Number of mutants that required at least one retry during the run.
-
#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.
-
#shutdown_requested? ⇒ Boolean
True once a graceful shutdown has been requested; read by the scheduler.
Constructor Details
#initialize(worker_count:, runtime: Runtime.new, wakeup: nil) ⇒ ProcessWorkerRunner
Returns a new instance of ProcessWorkerRunner.
38 39 40 41 42 43 |
# File 'lib/henitai/process_worker_runner.rb', line 38 def initialize(worker_count:, runtime: Runtime.new, wakeup: nil) @worker_count = worker_count @runtime = runtime @wakeup = wakeup @shutdown_requested = false end |
Instance Attribute Details
#runtime ⇒ Object (readonly)
Loop primitives the SlotScheduler reads back from its host.
36 37 38 |
# File 'lib/henitai/process_worker_runner.rb', line 36 def runtime @runtime end |
#wakeup ⇒ Object (readonly)
Loop primitives the SlotScheduler reads back from its host.
36 37 38 |
# File 'lib/henitai/process_worker_runner.rb', line 36 def wakeup @wakeup end |
#worker_count ⇒ Object (readonly)
Loop primitives the SlotScheduler reads back from its host.
36 37 38 |
# File 'lib/henitai/process_worker_runner.rb', line 36 def worker_count @worker_count end |
Instance Method Details
#flaky_retry_count ⇒ Object
Number of mutants that required at least one retry during the run. Mirrors the linear path’s per-mutant flaky semantics so the engine can report a single, mode-agnostic flaky statistic.
48 49 50 |
# File 'lib/henitai/process_worker_runner.rb', line 48 def flaky_retry_count @scheduler ? @scheduler.flaky_retry_count : 0 end |
#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.
59 60 61 62 |
# File 'lib/henitai/process_worker_runner.rb', line 59 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.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/henitai/process_worker_runner.rb', line 72 def run(mutants, integration, config, progress_reporter, = {}) Integration::SchedulerDiagnostics.reset! if Integration::SchedulerDiagnostics.enabled? prepare_run(mutants, integration, config, progress_reporter, ) event_loop @scheduler.results ensure @wakeup&.close @wakeup = nil end |
#shutdown_requested? ⇒ Boolean
True once a graceful shutdown has been requested; read by the scheduler.
53 54 55 |
# File 'lib/henitai/process_worker_runner.rb', line 53 def shutdown_requested? @shutdown_requested end |