Sha256: 7cd872015e39c509c087de57edfac66cc443a17b5f32113f06b2a0fe1fc0f4f0
Contents?: true
Size: 966 Bytes
Versions: 3
Compression:
Stored size: 966 Bytes
Contents
require_relative 'core_ext' require_relative 'worker_thread' require_relative 'logging' require_relative 'worker' module Upperkut class Manager attr_accessor :worker attr_reader :stopped, :logger, :concurrency def initialize(opts = {}) self.worker = opts.fetch(:worker).constantize @concurrency = opts.fetch(:concurrency, 1) @logger = opts.fetch(:logger, Logging.logger) @stopped = false @threads = [] end def run @concurrency.times do spawn_thread end end def stop @stopped = true @threads.each(&:stop) end def kill @threads.each(&:kill) end def notify_killed_processor(thread) @threads.delete(thread) spawn_thread unless @stopped end private def spawn_thread processor = Processor.new(worker, logger) thread = WorkerThread.new(self, processor) @threads << thread thread.run end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
upperkut-1.0.4 | lib/upperkut/manager.rb |
upperkut-1.0.2 | lib/upperkut/manager.rb |
upperkut-1.0.0.rc | lib/upperkut/manager.rb |