if I call `await` inside a suspendable function, h...
# coroutines
r
if I call
await
inside a suspendable function, how does that affect the scalability? I did this small test which models my real code to find out
Copy code
package rrva.mashup

import kotlinx.coroutines.experimental.*

fun fetchBarDeferred(n: Int): Deferred<Int> {
    return async(CommonPool) {
        delay(1000)
        n
    }
}

suspend fun fetchFoo(n: Int): Int {
    val resp = fetchBarDeferred(n)
    return resp.await() * 2
}

fun asyncFetchFoo(n: Int) = async(CommonPool) {
    fetchFoo(n)
}

fun main(args: Array<String>) {
    runBlocking {
        val numbers = (1..10000).map { n -> asyncFetchFoo(n) }.map { deferred -> deferred.await() }
        println(numbers.size)
    }

}
Looks like await() inside
fetchFoo
allows the coroutine to be suspended at that point?