Class: Larva::WorkerPool
Instance Attribute Summary collapse
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(processors) ⇒ WorkerPool
constructor
A new instance of WorkerPool.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(processors) ⇒ WorkerPool
Returns a new instance of WorkerPool.
8 9 10 |
# File 'lib/larva/worker_pool.rb', line 8 def initialize(processors) @processors = processors end |
Instance Attribute Details
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
7 8 9 |
# File 'lib/larva/worker_pool.rb', line 7 def processors @processors end |
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
7 8 9 |
# File 'lib/larva/worker_pool.rb', line 7 def workers @workers end |
Class Method Details
.start(processors) ⇒ Object
3 4 5 |
# File 'lib/larva/worker_pool.rb', line 3 def self.start(processors) new(processors).start end |
Instance Method Details
#start ⇒ Object
12 13 14 15 16 |
# File 'lib/larva/worker_pool.rb', line 12 def start @running = true start_workers keep_workers_alive if workers.count > 0 end |
#stop ⇒ Object
18 19 20 21 |
# File 'lib/larva/worker_pool.rb', line 18 def stop logger.info "Request to stop worker pool accepted" @running = false end |