Class: Promiscuous::Subscriber::Worker::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/promiscuous/subscriber/worker/runner.rb

Defined Under Namespace

Classes: RunnerThread

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Runner

Returns a new instance of Runner.



4
5
6
7
# File 'lib/promiscuous/subscriber/worker/runner.rb', line 4

def initialize(root)
  @root = root
  @messages_to_process = Queue.new
end

Instance Attribute Details

#messages_to_processObject

Returns the value of attribute messages_to_process.



2
3
4
# File 'lib/promiscuous/subscriber/worker/runner.rb', line 2

def messages_to_process
  @messages_to_process
end

Instance Method Details

#show_stop_status(num_requests) ⇒ Object



23
24
25
# File 'lib/promiscuous/subscriber/worker/runner.rb', line 23

def show_stop_status(num_requests)
  @runner_threads.to_a.each { |runner_thread| runner_thread.show_stop_status(num_requests) }
end

#startObject



9
10
11
12
# File 'lib/promiscuous/subscriber/worker/runner.rb', line 9

def start
  num_threads = Promiscuous::Config.subscriber_threads
  @runner_threads ||= num_threads.times.map { RunnerThread.new(@messages_to_process) }
end

#stopObject



14
15
16
17
18
19
20
21
# File 'lib/promiscuous/subscriber/worker/runner.rb', line 14

def stop
  return unless @runner_threads

  @runner_threads.each { |runner_thread| runner_thread.stop }
  @runner_threads = nil

  @messages_to_process.clear
end