Class: Dynflow::Executors::Parallel::SequenceCursor

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

Instance Method Summary collapse

Constructor Details

#initialize(flow_manager, sequence, parent_cursor = nil) ⇒ SequenceCursor

Returns a new instance of SequenceCursor.



6
7
8
9
10
11
12
13
# File 'lib/dynflow/executors/parallel/sequence_cursor.rb', line 6

def initialize(flow_manager, sequence, parent_cursor = nil)
  @flow_manager    = flow_manager
  @sequence        = sequence
  @parent_cursor   = parent_cursor
  @todo            = []
  @index           = -1 # starts before first element
  @no_error_so_far = true
end

Instance Method Details

#done?Boolean

return true if we can’t move the cursor further, either when everyting is done in the sequence or there was some failure that prevents us from moving

Returns:

  • (Boolean)


37
38
39
# File 'lib/dynflow/executors/parallel/sequence_cursor.rb', line 37

def done?
  (!@no_error_so_far && done_here?) || @index == @sequence.size
end

#what_is_next(work = nil, success = true) ⇒ Array<Integer>

Returns new step_ids that can be done next.

Parameters:

Returns:

  • (Array<Integer>)

    new step_ids that can be done next



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dynflow/executors/parallel/sequence_cursor.rb', line 19

def what_is_next(work = nil, success = true)
  unless work.nil? || @todo.delete(work)
    raise "marking as done work that was not expected: #{work.inspect}"
  end

  @no_error_so_far &&= success

  if done_here?
    return next_steps
  else
    return []
  end
end