Sha256: ba8e603c772d4d16d061d1f371d6cd8970990d206cb0373cbf8941fe9fa792a3
Contents?: true
Size: 677 Bytes
Versions: 57
Compression:
Stored size: 677 Bytes
Contents
module Dynflow # A simple round-robin scheduling implementation used at various # places in Dynflow class RoundRobin def initialize @data = [] @cursor = 0 end def add(item) @data.push item self end def delete(item) @data.delete item self end def next @cursor = 0 if @cursor > @data.size-1 @data[@cursor] ensure @cursor += 1 end def empty? @data.empty? end # 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 attr_writer :data end end
Version data entries
57 entries across 57 versions & 1 rubygems