Class: Build::Graph::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/build/graph/edge.rb

Overview

Represents an input to a graph node, with count inputs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count = 0) ⇒ Edge

Returns a new instance of Edge.



27
28
29
30
31
32
# File 'lib/build/graph/edge.rb', line 27

def initialize(count = 0)
  @fiber = Fiber.current
  @count = count

  @failed = []
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



37
38
39
# File 'lib/build/graph/edge.rb', line 37

def count
  @count
end

#failedObject (readonly)

Returns the value of attribute failed.



34
35
36
# File 'lib/build/graph/edge.rb', line 34

def failed
  @failed
end

#fiberObject (readonly)

Returns the value of attribute fiber.



36
37
38
# File 'lib/build/graph/edge.rb', line 36

def fiber
  @fiber
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/build/graph/edge.rb', line 49

def failed?
  @failed.size != 0
end

#increment!Object



65
66
67
# File 'lib/build/graph/edge.rb', line 65

def increment!
  @count += 1
end

#traverse(node) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/build/graph/edge.rb', line 53

def traverse(node)
  @count -= 1

  if node.failed?
    @failed << node
  end

  if @count == 0
    @fiber.resume
  end
end

#waitObject



39
40
41
42
43
44
45
# File 'lib/build/graph/edge.rb', line 39

def wait
  if @count > 0
    Fiber.yield
  end

  failed?
end