class Async::Node

Represents a node in a tree, used for nested {Task} instances.

def consume

the parent.
If the node has a parent, and is {finished?}, then remove this node from
def consume
	if @parent && finished?
		@parent.reap(self)
		@parent.consume
		@parent = nil
	end
end

def finished?

Returns:
  • (Boolean) -
def finished?
	@children.empty?
end

def initialize(parent = nil)

Parameters:
  • parent (Node, nil) -- This node will attach to the given parent.
def initialize(parent = nil)
	@children = Set.new
	@parent = nil
	
	if parent
		self.parent = parent
	end
end

def parent=(parent)

Returns:
  • (self) -

Parameters:
  • parent (Node, nil) -- the parent to attach to, or nil to detach.
def parent=(parent)
	return if @parent.equal?(parent)
	
	if @parent
		@parent.reap(self)
		@parent = nil
	end
	
	if parent
		@parent = parent
		@parent.children << self
	end
	
	return self
end

def reap(child)

Parameters:
  • child (Node) --
def reap(child)
	@children.delete(child)
end