Class: Build::Graph::Edge
- Inherits:
-
Object
- Object
- Build::Graph::Edge
- Defined in:
- lib/build/graph/edge.rb
Overview
Represents an input to a graph node, with count inputs.
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#failed ⇒ Object
readonly
Returns the value of attribute failed.
-
#fiber ⇒ Object
readonly
Returns the value of attribute fiber.
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #increment! ⇒ Object
-
#initialize(count = 0) ⇒ Edge
constructor
A new instance of Edge.
- #traverse(node) ⇒ Object
- #wait ⇒ Object
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
#count ⇒ Object (readonly)
Returns the value of attribute count.
37 38 39 |
# File 'lib/build/graph/edge.rb', line 37 def count @count end |
#failed ⇒ Object (readonly)
Returns the value of attribute failed.
34 35 36 |
# File 'lib/build/graph/edge.rb', line 34 def failed @failed end |
#fiber ⇒ Object (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
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 |
#wait ⇒ Object
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 |