class Wamp::Worker::Runner::Background

This class monitors the queue and returns the descriptor

Attributes

callback[R]
thread[R]

Public Class Methods

new(name, uuid: nil, &callback) click to toggle source

Constructor

@param name [Symbol] - the name of the worker

Calls superclass method Wamp::Worker::Runner::Base::new
# File lib/wamp/worker/runner.rb, line 67
def initialize(name, uuid: nil, &callback)
  super name, uuid: uuid

  @callback = callback

  # Log the event
  logger.debug("#{self.class.name} '#{self.name}' created")
end

Public Instance Methods

_start() click to toggle source

Starts the background runner

# File lib/wamp/worker/runner.rb, line 78
def _start
  # Start the background thread
  Thread.new do

    # The background thread will infinitely call the callback while the
    # runner is active
    while self.active?
      begin
        self.callback.call(self)
      rescue => e
        logger.error("#{self.class.name} #{e.class.name} - #{e.message}")
      end
    end

  end
end