Class: ActiveConcurrency::Schedulers::RoundRobin
- Inherits:
-
Object
- Object
- ActiveConcurrency::Schedulers::RoundRobin
- Defined in:
- lib/active_concurrency/schedulers/round_robin.rb
Instance Method Summary collapse
-
#initialize(pool, _options) ⇒ RoundRobin
constructor
A new instance of RoundRobin.
- #schedule(*args, &block) ⇒ Object
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, ) 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 |