class Build::Graph::Edge

Represents a set of inputs to a graph node.

Attributes

count[R]
failed[R]
fiber[R]

Public Class Methods

new(count = 0) click to toggle source
# File lib/build/graph/edge.rb, line 27
def initialize(count = 0)
        @fiber = Fiber.current
        
        # The number of inputs we are waiting for:
        @count = count
        @vertices = 0
        
        @failed = []
end

Public Instance Methods

failed?() click to toggle source
# File lib/build/graph/edge.rb, line 51
def failed?
        @failed.size != 0
end
increment!() click to toggle source

Increase the number of traversals we are waiting for.

# File lib/build/graph/edge.rb, line 83
def increment!
        @vertices += 1
        @count += 1
end
skip!(task) click to toggle source

This is called in the case that a parent fails to complete because a child task has failed.

# File lib/build/graph/edge.rb, line 74
def skip!(task)
        @vertices += 1
        
        if task.failed?
                @failed << task
        end
end
succeeded?() click to toggle source
# File lib/build/graph/edge.rb, line 55
def succeeded?
        @failed.size == 0
end
traverse(task) click to toggle source

Traverse the edge, mark the edge as failed if the source was also failed.

# File lib/build/graph/edge.rb, line 60
def traverse(task)
        @count -= 1
        
        # The entire edge fails if any individual task fails.
        if task.failed?
                @failed << task
        end
        
        if @count == 0
                @fiber.resume
        end
end
wait() click to toggle source

Wait until all inputs to the edge have been traversed. Returns false if failed?

# File lib/build/graph/edge.rb, line 43
def wait
        if @count > 0
                Fiber.yield
        end
        
        succeeded?
end