Class: Dynflow::Executors::Parallel::Pool::RoundRobin
- Inherits:
-
Object
- Object
- Dynflow::Executors::Parallel::Pool::RoundRobin
- Defined in:
- lib/dynflow/executors/parallel/pool.rb
Instance Method Summary collapse
- #add(item) ⇒ Object
- #delete(item) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ RoundRobin
constructor
A new instance of RoundRobin.
- #next ⇒ Object
Constructor Details
#initialize ⇒ RoundRobin
Returns a new instance of RoundRobin.
6 7 8 9 |
# File 'lib/dynflow/executors/parallel/pool.rb', line 6 def initialize @data = [] @cursor = 0 end |
Instance Method Details
#add(item) ⇒ Object
11 12 13 14 |
# File 'lib/dynflow/executors/parallel/pool.rb', line 11 def add(item) @data.push item self end |
#delete(item) ⇒ Object
16 17 18 19 |
# File 'lib/dynflow/executors/parallel/pool.rb', line 16 def delete(item) @data.delete item self end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/dynflow/executors/parallel/pool.rb', line 26 def empty? @data.empty? end |
#next ⇒ Object
21 22 23 24 |
# File 'lib/dynflow/executors/parallel/pool.rb', line 21 def next @cursor = 0 if @cursor > @data.size-1 @data[@cursor].tap { @cursor += 1 } end |