Method: Build::Graph::Walker#wait_for_children

Defined in:
lib/build/graph/walker.rb

#wait_for_children(parent, children) ⇒ Object

A parent task only completes once all it’s children are complete.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/build/graph/walker.rb', line 121

def wait_for_children(parent, children)
  # Consider only incomplete/failed children:
  children = children.select{|child| !child.complete?}
  
  # If there are no children like this, then done:
  return true if children.size == 0
  
  # Otherwise, construct an edge to track state changes:
  edge = Edge.new
  
  children.each do |child|
    if child.failed?
      edge.skip!(child)
    else
      # We are waiting for this child to finish:
      edge.increment!
      
      @parents[child.node] ||= []
      @parents[child.node] << edge
    end
  end
  
  return edge.wait
end