Class: ActiveMutator::Scheduler

Inherits:
Object
  • Object
show all
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).

Instance Method Summary collapse

Constructor Details

#initialize(jobs:, worker: Worker.method(:run), on_result: nil) ⇒ Scheduler

Returns a new instance of Scheduler.



8
9
10
11
12
# File 'lib/active_mutator/scheduler.rb', line 8

def initialize(jobs:, worker: Worker.method(:run), on_result: nil)
  @jobs = jobs
  @worker = worker
  @on_result = on_result
end

Instance Method Details

#run(items) ⇒ Object



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

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