Class: Upperkut::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/upperkut/processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(manager) ⇒ Processor

Returns a new instance of Processor.



5
6
7
8
9
10
11
12
# File 'lib/upperkut/processor.rb', line 5

def initialize(manager)
  @manager  = manager
  @worker   = @manager.worker
  @logger   = @manager.logger
  @strategy = @worker.strategy

  @sleeping_time = 0
end

Instance Method Details

#killObject



30
31
32
33
34
35
# File 'lib/upperkut/processor.rb', line 30

def kill
  return unless @thread

  @thread.raise Upperkut::Shutdown
  @thread.value # wait
end

#runObject



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

def run
  @thread ||= Thread.new do
    begin
      process
    rescue Exception => e
      @logger.debug(
        action: :processor_killed,
        reason: e,
        stacktrace: e.backtrace
      )

      @manager.notify_killed_processor(self)
    end
  end
end