I have a blocking call into an external library. I would like to have these calls run into a special pool, but I would like the calling coroutine to park - not block - while it’s waiting for the result computed on the pool.
I create a pool:
private val tpfContext = newFixedThreadPoolContext(4, "tpf-pool")
And then - by printing the theread name - I seem to get the same results, whether I do:
runBlocking(tpfContext) { ... }
or
async(tpfContext) { ... } .await()
Are they the same thing? because the docs for runBlocking
specify that the thread is blocked, but what happens if you specify a pool? which thread is blocked? Idea suggests that runBlocking
is the wrong construct.