Class: EventQ::WorkerStatus
- Inherits:
-
Object
- Object
- EventQ::WorkerStatus
- 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
-
#processes ⇒ Object
readonly
List of WorkerProcess.
Instance Method Summary collapse
-
#initialize ⇒ WorkerStatus
constructor
A new instance of WorkerStatus.
-
#pids ⇒ Object
Retrieve a simple list of all PIDS.
-
#threads ⇒ Object
Retrieve a simple list of all threads.
Constructor Details
#initialize ⇒ WorkerStatus
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
#processes ⇒ Object (readonly)
List of WorkerProcess
16 17 18 |
# File 'lib/eventq/worker_status.rb', line 16 def processes @processes end |
Instance Method Details
#pids ⇒ Object
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 |
#threads ⇒ Object
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 |