Class: CobraCommander::Executor::WorkerPool::Worker
- Inherits:
-
Object
- Object
- CobraCommander::Executor::WorkerPool::Worker
- Defined in:
- lib/cobra_commander/executor/worker_pool.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id, pool) ⇒ Worker
constructor
A new instance of Worker.
- #kill ⇒ Object
- #spawn ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(id, pool) ⇒ Worker
Returns a new instance of Worker.
36 37 38 39 |
# File 'lib/cobra_commander/executor/worker_pool.rb', line 36 def initialize(id, pool) @id = id @pool = pool end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
34 35 36 |
# File 'lib/cobra_commander/executor/worker_pool.rb', line 34 def id @id end |
Instance Method Details
#kill ⇒ Object
41 42 43 |
# File 'lib/cobra_commander/executor/worker_pool.rb', line 41 def kill @thread&.kill end |
#spawn ⇒ Object
45 46 47 48 49 |
# File 'lib/cobra_commander/executor/worker_pool.rb', line 45 def spawn @thread = Thread.new do loop { break if @pool.run_next == :exit } end end |
#wait ⇒ Object
51 52 53 |
# File 'lib/cobra_commander/executor/worker_pool.rb', line 51 def wait @thread.join end |