class Async::Node

def consume

def consume
	if @parent && finished?
		@parent.reap(self)
		@parent.consume
		@parent = nil
	end
end

def finished?

def finished?
	@children.empty?
end

def initialize(parent = nil)

def initialize(parent = nil)
	@children = Set.new
	@parent = nil
	
	if parent
		self.parent = parent
	end
end

def parent=(parent)

Attach this node to an existing parent.
def parent=(parent)
	return if @parent.equal?(parent)
	
	if @parent
		@parent.reap(self)
		@parent = nil
	end
	
	if parent
		@parent = parent
		@parent.children << self
	end
end

def reap(child)

def reap(child)
	@children.delete(child)
end