Class: Upperkut::WorkerThread
- Inherits:
-
Object
- Object
- Upperkut::WorkerThread
- Defined in:
- lib/upperkut/worker_thread.rb
Instance Method Summary collapse
-
#initialize(manager, processor) ⇒ WorkerThread
constructor
A new instance of WorkerThread.
- #kill ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(manager, processor) ⇒ WorkerThread
Returns a new instance of WorkerThread.
5 6 7 8 |
# File 'lib/upperkut/worker_thread.rb', line 5 def initialize(manager, processor) @manager = manager @processor = processor end |
Instance Method Details
#kill ⇒ Object
30 31 32 33 34 35 |
# File 'lib/upperkut/worker_thread.rb', line 30 def kill return unless @thread @thread.raise Upperkut::Shutdown @thread.value # wait end |
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/upperkut/worker_thread.rb', line 10 def run @thread ||= Thread.new do begin @processor.blocking_process rescue Exception => e @manager.logger.debug( action: :processor_killed, reason: e, stacktrace: e.backtrace ) @manager.notify_killed_processor(self) end end end |
#stop ⇒ Object
26 27 28 |
# File 'lib/upperkut/worker_thread.rb', line 26 def stop @processor.stop end |