type task … func (x *task) isTransitivelyDone() bool { … } // addEdge creates an edge from x to y, indicating that // x.wait() will not return before y is done. // All calls to x.addEdge(...) should happen before x.markDone(). func (x *task) addEdge(y *task) { … } // markDone changes the task's state to markDone. func (x *task) markDone() { … } // wait blocks until x and all the tasks it can reach through edges are done. func (x *task) wait() { … }