Skip to content

Commit

Permalink
better async parallel hook
Browse files Browse the repository at this point in the history
  • Loading branch information
sugarmanz committed Oct 26, 2021
1 parent 40cc1bc commit ebfdb97
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions hooks/src/main/kotlin/com/intuit/hooks/AsyncParallelHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ public abstract class AsyncParallelHook<F : Function<*>> : AsyncBaseHook<F>("Asy
protected suspend fun call(invokeWithContext: suspend (F, HookContext) -> Unit) {
val context = setup(invokeWithContext)

return taps.map { tapInfo ->
coroutineScope {
coroutineScope {
taps.forEach { tapInfo ->
launch {
invokeWithContext(tapInfo.f, context)
}
}
}.forEach {
it.join()
}
}
}

0 comments on commit ebfdb97

Please sign in to comment.