Class: ActiveMutator::Scheduler
- Inherits:
-
Object
- Object
- ActiveMutator::Scheduler
- Defined in:
- lib/active_mutator/scheduler.rb
Overview
Fork pool: one fork per WorkItem, capped at jobs concurrent forks.
Parent enforces per-item deadlines with SIGKILL (worker-side timeouts
cannot interrupt all infinite loops).
Constant Summary collapse
- OrphanedError =
Class.new(Error)
Instance Method Summary collapse
-
#initialize(jobs:, worker: Worker.method(:run), on_result: nil, orphaned: -> { Process.ppid == 1 }) ⇒ Scheduler
constructor
A new instance of Scheduler.
- #run(items) ⇒ Object
Constructor Details
#initialize(jobs:, worker: Worker.method(:run), on_result: nil, orphaned: -> { Process.ppid == 1 }) ⇒ Scheduler
Returns a new instance of Scheduler.
10 11 12 13 14 15 16 |
# File 'lib/active_mutator/scheduler.rb', line 10 def initialize(jobs:, worker: Worker.method(:run), on_result: nil, orphaned: -> { Process.ppid == 1 }) @jobs = jobs @worker = worker @on_result = on_result @orphaned = orphaned end |
Instance Method Details
#run(items) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_mutator/scheduler.rb', line 18 def run(items) previous_traps = nil running = {} previous_traps = install_signal_handlers(running) results = [] # Browser-covered mutants each boot Chrome + an app server; running them # concurrently melts CPUs and manufactures false timeouts. Parallel lane # first at full width, then the serial lane one at a time. results.concat(run_pool(items.select { |i| i.lane == :parallel }, @jobs, running)) results.concat(run_pool(items.select { |i| i.lane == :serial }, 1, running)) results ensure restore_traps(previous_traps) if previous_traps end |