Class: EventQ::WorkerStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/eventq/worker_status.rb

Overview

Class used to represent the main worker status and the collection of forked worker processes. The main worker process will not have access to a forks collection of processes and threads. This is due to forks getting a copy of the process memory space and there is no such thing as shared resources between child processes and the parent process. Without implementing a need using inter process communication with IO::Pipe, only the PID is of any use for the parent process. To summarize, if using forks, the parent process will only have a collection of PIDS and not any threads associated with those PIDS.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWorkerStatus

Returns a new instance of WorkerStatus.



18
19
20
# File 'lib/eventq/worker_status.rb', line 18

def initialize
  @processes = Concurrent::Array.new
end

Instance Attribute Details

#processesObject (readonly)

List of WorkerProcess



16
17
18
# File 'lib/eventq/worker_status.rb', line 16

def processes
  @processes
end

Instance Method Details

#pidsObject

Retrieve a simple list of all PIDS.



23
24
25
26
27
28
29
# File 'lib/eventq/worker_status.rb', line 23

def pids
  list = []
  @processes.each do |p|
    list.push(p.pid)
  end
  list
end

#threadsObject

Retrieve a simple list of all threads. Important Note: The list of threads is only relevant to the current process.



33
34
35
36
37
38
39
40
41
42
# File 'lib/eventq/worker_status.rb', line 33

def threads
  list = []
  @processes.each do |p|
    p.threads.each do |t|
      list.push(t)
    end
  end

  list
end