Class: Messagebus::Swarm::Controller::ProcessManagementConcerns::DroneThreader
- Inherits:
-
Object
- Object
- Messagebus::Swarm::Controller::ProcessManagementConcerns::DroneThreader
- Defined in:
- lib/messagebus/swarm/controller.rb
Instance Method Summary collapse
-
#initialize(drones) ⇒ DroneThreader
constructor
A new instance of DroneThreader.
- #start ⇒ Object
- #stop ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(drones) ⇒ DroneThreader
Returns a new instance of DroneThreader.
188 189 190 |
# File 'lib/messagebus/swarm/controller.rb', line 188 def initialize(drones) @drones = drones end |
Instance Method Details
#start ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/messagebus/swarm/controller.rb', line 192 def start @threads = @drones.map do |drone| Thread.new do drone.processing_loop end end end |
#stop ⇒ Object
204 205 206 |
# File 'lib/messagebus/swarm/controller.rb', line 204 def stop @drones.each(&:stop) end |
#wait ⇒ Object
200 201 202 |
# File 'lib/messagebus/swarm/controller.rb', line 200 def wait @threads.each(&:join) end |