Sha256: 8abe41e0cce278d8a2f2ddafdcd2c0dfd824473f41c2e249cfb72b8647871679
Contents?: true
Size: 709 Bytes
Versions: 2
Compression:
Stored size: 709 Bytes
Contents
# frozen_string_literal: true 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynflow-1.9.0 | lib/dynflow/round_robin.rb |
dynflow-1.8.3 | lib/dynflow/round_robin.rb |