What's the coroutine status? If my response needs ...
# http4k
m
What's the coroutine status? If my response needs to call a suspend fun, should I just
runBlocking {}
? What's everyone doing there?
d
as per @dmcg's videos around this, I think the sensible answer is to use a loom dispatcher and run it like so (if you're using a loom-enabled VM 🙂. ):
Copy code
val loomDispatcher = Executors.newVirtualThreadPerTaskExecutor().asCoroutineDispatcher()

fun <T, R> (suspend (T) -> R).runningOn(
    dispatcher: CoroutineDispatcher
): (T) -> R = {
    runBlocking(dispatcher) {
        this@runningOn(it)
    }
}
👀 1
thank you color 1
m
Thanks! Video is

this oneâ–¾

?
d
I think that it the first place I played with
newVirtualThreadPerTaskExecutor
. You might need

https://youtu.be/I4NRT--Bj3Qâ–¾

and

https://youtu.be/ACk2HkvVKnAâ–¾

for context
👀 1