Class: RestFtpDaemon::WorkerPool
- Inherits:
-
Object
- Object
- RestFtpDaemon::WorkerPool
- Includes:
- NewRelic::Agent::Instrumentation::ControllerInstrumentation, LoggerHelper
- Defined in:
- lib/rest-ftp-daemon/worker_pool.rb
Overview
Handles a pool of Worker objects
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#wid ⇒ Object
readonly
Returns the value of attribute wid.
Instance Method Summary collapse
-
#initialize ⇒ WorkerPool
constructor
A new instance of WorkerPool.
- #worker_alive?(wid) ⇒ Boolean
- #worker_variables ⇒ Object
Constructor Details
#initialize ⇒ WorkerPool
Returns a new instance of WorkerPool.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rest-ftp-daemon/worker_pool.rb', line 14 def initialize # Logger @logger = RestFtpDaemon::LoggerPool.instance.get :workers # Prepare status hash and vars @statuses = {} @workers = {} @conchita = nil @mutex = Mutex.new # Identifiers generator @last_id = 0 # Create worker threads create_threads end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/rest-ftp-daemon/worker_pool.rb', line 6 def logger @logger end |
#wid ⇒ Object (readonly)
Returns the value of attribute wid.
8 9 10 |
# File 'lib/rest-ftp-daemon/worker_pool.rb', line 8 def wid @wid end |
Instance Method Details
#worker_alive?(wid) ⇒ Boolean
41 42 43 |
# File 'lib/rest-ftp-daemon/worker_pool.rb', line 41 def worker_alive? wid @workers[wid] && @workers[wid].alive? end |
#worker_variables ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/rest-ftp-daemon/worker_pool.rb', line 31 def worker_variables @workers.collect do |_wid, worker| vars = {} worker.thread_variables.each do |var| vars[var] = worker.thread_variable_get var end vars end end |