elizarov
06/04/2017, 1:53 PMwaiFor
just waitFor(predecessors: Tasks) = predecessors.forEach { it.await() }
works just as finenkiesel
06/04/2017, 4:25 PMsuspend fun Tasks.await() = forEach { it.await() }
.
One problem with this approach is that I need to create tasks in their topological order / partially sorted. Would be nicer if I could hide this (i.e. somehow allow callers to add nodes and edges of the dependency graph in any order). Any ideas? or Is there another coroutine construct that would no rely on the topological order?elizarov
06/05/2017, 8:12 PMnkiesel
06/06/2017, 7:35 AMelizarov
06/06/2017, 7:52 AMexecute(recipe)
that takes a recipe and performs whatever action is needed. Each recipe has a list of predecessor recipes. I suggest to keep a Map<Recipe, Job>
that is lazily initialised. When a task has predecessors it looks up or creates a jobs for them, then waits on their jobs before executing its own recipe.nkiesel
06/06/2017, 9:17 AMelizarov
06/06/2017, 9:18 AMasync(context) { awaitPredecessors(); execute(receipe) }
nkiesel
06/06/2017, 11:21 PMelizarov
06/07/2017, 5:54 AMnkiesel
06/07/2017, 6:37 AM