parallelVisitThen

fun parallelVisitThen(visitAction: (Vertex, () -> Unit) -> Unit, afterTraversal: () -> Unit)

Visit the vertices in DAG order. The action is invoked for each vertex, also passing a completion action to invoke when that vertex visit is considered complete, allowing successors for which all predecessors have completed to be visited.

The afterTraversal action runs at the end of the last completed vertex's completion action (passed as the second argument to the visitAction). Thus, if the completion actions always run in the same Thread as the visitAction, the graph is effectively traversed serially, running the afterTraversal action at the end, just before returning from this method.

The receiver must not be cyclic.

Parameters

visitAction

What to do for each vertex. The action takes the vertex and a zero-argument action to run when processing the vertex is considered finished (with regard to ordering the traversal).

afterTraversal

What to do after traversing the entire graph.