Class: Dynflow::Executors::Parallel::Pool::RoundRobin

Inherits:
Object
  • Object
show all
Defined in:
lib/dynflow/executors/parallel/pool.rb

Instance Method Summary collapse

Constructor Details

#initializeRoundRobin

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/dynflow/executors/parallel/pool.rb', line 26

def empty?
  @data.empty?
end

#nextObject



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