Dave Jensen
01/31/2020, 12:21 AMoctylFractal
01/31/2020, 12:23 AMList<Deferred<T>>
, awaitAll(): List<T>
Dave Jensen
01/31/2020, 12:26 AMoctylFractal
01/31/2020, 12:32 AMFlow
may be useful, but it doesn't yet have good concurrency primitives, it's best for serial processing. You can emulate concurrent processing by using .map { async { } }
and .buffered
, but it's certainly more complex than thisDave Jensen
01/31/2020, 12:48 AMgetInt
contains a blocking call? Like an http library that doesn't support coroutines?octylFractal
01/31/2020, 12:49 AMsuspend
function + withContext(<http://Dispatchers.IO|Dispatchers.IO>)
, e.g.:
suspend fun suspendGetInt(i: Int) = withContext(<http://Dispatchers.IO|Dispatchers.IO>) { getInt(i) }
Dave Jensen
01/31/2020, 12:55 AMoctylFractal
01/31/2020, 1:05 AMDave Jensen
01/31/2020, 1:05 AMoctylFractal
01/31/2020, 1:06 AM.then
is basically a callback)