Is there a way to take say a sequence of `Foo`, ru...
# coroutines
s
Is there a way to take say a sequence of
Foo
, run
Bar
on all of the `Foo`s in parallel, then rejoin the results of
Bar(Foo)
as an iterable of
Foo
in the original order they were given? Suppose
Bar(Foo)
will not run the same amount of time per
Foo
.
u
something like
Copy code
sequence
.map {
 async { Foo(Bar) }
}.map { 
 it.await() 
}
s
I think you’d actually want to do async for all then call awaitAll on all of the deferreds, but not sure. I don’t actually know if
map
runs sequentially on all elements before yielding to the next function (in Java streams, I think it’s not well defined).