Sha256: 5a9dae053d36ce35ba3d623f44446016094821bfc307a653a8b54013e9e3a8c6

Contents?: true

Size: 689 Bytes

Versions: 3

Compression:

Stored size: 689 Bytes

Contents

require_relative 'processor'

module Upperkut
  class WorkerThread
    def initialize(manager, processor)
      @manager = manager
      @processor = processor
    end

    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

    def stop
      @processor.stop
    end

    def kill
      return unless @thread

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
upperkut-1.0.4 lib/upperkut/worker_thread.rb
upperkut-1.0.2 lib/upperkut/worker_thread.rb
upperkut-1.0.0.rc lib/upperkut/worker_thread.rb