Sha256: 1cc309d0dee40843f47bb64d1fcdd6a67f8654c6395eef835dcfccdd251d56e6
Contents?: true
Size: 1011 Bytes
Versions: 4
Compression:
Stored size: 1011 Bytes
Contents
module GoodJob # Delegates the interface of a single {Scheduler} to multiple Schedulers. class MultiScheduler # @return [array<Scheduler>] List of the scheduler delegates attr_reader :schedulers def initialize(schedulers) @schedulers = schedulers end # Delegates to {Scheduler#shutdown}. def shutdown(wait: true) schedulers.each { |s| s.shutdown(wait: wait) } end # Delegates to {Scheduler#shutdown?}. def shutdown? schedulers.all?(&:shutdown?) end # Delegates to {Scheduler#restart}. def restart(wait: true) schedulers.each { |s| s.restart(wait: wait) } end # Delegates to {Scheduler#create_thread}. def create_thread(state = nil) results = [] any_true = schedulers.any? do |scheduler| scheduler.create_thread(state).tap { |result| results << result } end if any_true true else results.any? { |result| result == false } ? false : nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems