class Dynflow::RoundRobin
A simple round-robin scheduling implementation used at various places in Dynflow
Attributes
data[W]
the `add` and `delete` methods should be preferred, but sometimes the list of things to iterate though can not be owned by the round robin object itself
Public Class Methods
new()
click to toggle source
# File lib/dynflow/round_robin.rb, line 6 def initialize @data = [] @cursor = 0 end
Public Instance Methods
add(item)
click to toggle source
# File lib/dynflow/round_robin.rb, line 11 def add(item) @data.push item self end
delete(item)
click to toggle source
# File lib/dynflow/round_robin.rb, line 16 def delete(item) @data.delete item self end
empty?()
click to toggle source
# File lib/dynflow/round_robin.rb, line 28 def empty? @data.empty? end
next()
click to toggle source
# File lib/dynflow/round_robin.rb, line 21 def next @cursor = 0 if @cursor > @data.size-1 @data[@cursor] ensure @cursor += 1 end