Class: Larva::WorkerPool

Inherits:
Object show all
Defined in:
lib/larva/worker_pool.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#processorsObject (readonly)

Returns the value of attribute processors.



7
8
9
# File 'lib/larva/worker_pool.rb', line 7

def processors
  @processors
end

#workersObject (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

#startObject



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

#stopObject



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