Class: Cosmo::Job::Processor

Inherits:
Processor show all
Defined in:
lib/cosmo/job/processor.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Methods inherited from Processor

run, #run

Constructor Details

#initialize(pool, running, options) ⇒ Processor

Returns a new instance of Processor.



6
7
8
9
# File 'lib/cosmo/job/processor.rb', line 6

def initialize(pool, running, options)
  super
  @weights = []
end

Instance Method Details

#stop(timeout = ) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/cosmo/job/processor.rb', line 11

def stop(timeout = Config[:timeout])
  @running.make_false
  @pool.shutdown
  @consumers.each { |(s, _)| s.unsubscribe rescue nil }
  @pool.wait_for_termination(timeout)
  [@work_thread, @schedule_thread].compact.each { _1.join(timeout) || _1.kill }
  @consumers.clear
end