Class: QueueToTheFuture::Worker
- Inherits:
-
Object
- Object
- QueueToTheFuture::Worker
- Defined in:
- lib/queue_to_the_future/worker.rb
Instance Method Summary collapse
- #dispatch ⇒ Object
-
#initialize(index) ⇒ Worker
constructor
A new instance of Worker.
Constructor Details
#initialize(index) ⇒ Worker
Returns a new instance of Worker.
3 4 5 6 7 |
# File 'lib/queue_to_the_future/worker.rb', line 3 def initialize(index) @index = index @coordinator = Coordinator.instance dispatch end |
Instance Method Details
#dispatch ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/queue_to_the_future/worker.rb', line 9 def dispatch Thread.new(@index) do |index| while index < QueueToTheFuture.maximum_workers && (work = @coordinator.next_job) work.__execute__ Thread.pass() end @coordinator.relieve(self) end end |