Sha256: 1fd64db422de06fd477f20e08b15a4256ec0e440a9922eca143b7d89852f646d

Contents?: true

Size: 440 Bytes

Versions: 2

Compression:

Stored size: 440 Bytes

Contents

module QueueToTheFuture
  class Worker
    def initialize(index)
      @index        = index
      @coordinator  = Coordinator.instance
      dispatch
    end
    
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
queue_to_the_future-0.1.1 lib/queue_to_the_future/worker.rb
queue_to_the_future-0.1.0 lib/queue_to_the_future/worker.rb