David Glasser
05/26/2020, 9:35 PMsuspend (I)->O
. I’d like to get the List<O>
out, running a bounded number of copies of the mapping function in parallel. I feel like this should be straightforward, eg with Flow, but I can’t quite get it to workDavid Glasser
05/26/2020, 9:36 PMin.asFlow().buffer(N).map(f)
or in.asFlow().flatMapMerge{ flow { emit (f(it)) } }
David Glasser
05/26/2020, 9:38 PMmap { async { f(it) } }.awaitAll()
which seems “unbounded” but that’s fine i supposebezrukov
05/26/2020, 9:53 PMconcurrency
param in flatMapMergebezrukov
05/26/2020, 9:55 PMDavid Glasser
05/26/2020, 9:55 PMbezrukov
05/26/2020, 9:55 PMDavid Glasser
05/26/2020, 9:56 PMDavid Glasser
05/26/2020, 9:57 PMbezrukov
05/26/2020, 10:03 PMmap { async(yourDispatcher) { f(it) } }.awaitAll()
but it looks like overkill as well.
there was a ticket for re-implementation fixedThreadPoolContext to avoid creation real dispatcher, but there is no eta.Dominaezzz
05/26/2020, 11:12 PMSemaphore
!