Sha256: 6102674e46a2cbbc05f68563d08b9cdaad5278149ad6acd95729d31284cf41f5

Contents?: true

Size: 584 Bytes

Versions: 2

Compression:

Stored size: 584 Bytes

Contents

require 'build/error'

module Build
	# Represents an input to a graph node, with count inputs.
	class Edge
		def initialize(count = 0)
			@fiber = Fiber.current
			@count = count
			
			@failed = []
		end
		
		attr :failed
		
		attr :fiber
		attr :count
		
		def wait
			if @count > 0
				Fiber.yield
			end
			
			failed?
		end
		
		attr :failed
		
		def failed?
			@failed.size != 0
		end
		
		def traverse(node)
			@count -= 1
			
			if node.failed?
				@failed << node
			end
			
			if @count == 0
				@fiber.resume
			end
		end
		
		def increment!
			@count += 1
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
build-graph-0.1.0 lib/build/edge.rb
build-graph-0.0.1 lib/build/edge.rb