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
# File 'lib/upperkut/processor.rb', line 5

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

  @sleeping_time = 0
end

Instance Method Details

#killObject



28
29
30
31
32
# File 'lib/upperkut/processor.rb', line 28

def kill
  return unless @thread
  @thread.raise Upperkut::Shutdown
  @thread.value # wait
end

#runObject



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

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

      @manager.notify_killed_processor(self)
    end
  end
end