Class: ActiveConcurrency::Schedulers::RoundRobin

Inherits:
Object
  • Object
show all
Defined in:
lib/active_concurrency/schedulers/round_robin.rb

Instance Method Summary collapse

Constructor Details

#initialize(pool, _options) ⇒ RoundRobin

Returns a new instance of RoundRobin.



7
8
9
10
# File 'lib/active_concurrency/schedulers/round_robin.rb', line 7

def initialize(pool, _options)
  mutex = Mutex.new
  @pool = pool.each { |w| w.mutex = mutex }.cycle
end

Instance Method Details

#schedule(*args, &block) ⇒ Object



12
13
14
15
# File 'lib/active_concurrency/schedulers/round_robin.rb', line 12

def schedule(*args, &block)
  worker = @pool.next
  worker.schedule(*args, &block)
end