musikr: re-add removed flow buffer
This commit is contained in:
@@ -48,17 +48,18 @@ internal fun <T, R> Flow<T>.distributedMap(
|
||||
val posChannels = List(n) { Channel<T>(Channel.UNLIMITED) }
|
||||
val managerFlow =
|
||||
flow<Nothing> {
|
||||
withIndex().collect {
|
||||
val index = it.index % n
|
||||
posChannels[index].send(it.value)
|
||||
withIndex().collect {
|
||||
val index = it.index % n
|
||||
posChannels[index].send(it.value)
|
||||
}
|
||||
for (channel in posChannels) {
|
||||
channel.close()
|
||||
}
|
||||
}
|
||||
for (channel in posChannels) {
|
||||
channel.close()
|
||||
}
|
||||
}.buffer()
|
||||
.buffer()
|
||||
return (posChannels.map { it.receiveAsFlow() } + managerFlow)
|
||||
.asFlow()
|
||||
.map { it.tryMap(block).flowOn(on) }
|
||||
.map { it.tryMap(block).flowOn(on).buffer(buffer) }
|
||||
.flattenMerge(concurrency = n + 1)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user