lib/fasten/runner.rb in fasten-0.10.0 vs lib/fasten/runner.rb in fasten-0.12.0
- old
+ new
@@ -9,11 +9,11 @@
require 'fasten/support/ui'
require 'fasten/support/yaml'
require 'fasten/timeout_queue'
module Fasten
- class Runner
+ class Runner # rubocop:disable Metrics/ClassLength
include Fasten::Support::Logger
include Fasten::Support::State
include Fasten::Support::Stats
include Fasten::Support::UI
include Fasten::Support::Yaml
@@ -215,11 +215,11 @@
ui.force_clear
end
end
end
- def find_or_create_worker(worker_class: )
+ def find_or_create_worker(worker_class:)
worker = workers.find { |item| item.class == worker_class && item.running_task.nil? }
unless worker
@worker_id = (@worker_id || 0) + 1
worker = worker_class.new runner: self, name: "#{worker_class.to_s.gsub('::', '-')}-#{format '%02X', @worker_id}", use_threads: use_threads
@@ -233,10 +233,10 @@
worker
end
def dispatch_pending_tasks
- while tasks.waiting? && tasks.running.count < jobs
+ while tasks.waiting? && tasks.running.map(&:weight).sum < jobs
task = tasks.next
task_worker_class = task.worker_class || worker_class
task_worker_class = Object.const_get(task_worker_class) if task_worker_class.is_a? String