You can use non-blocking network API, such as Java...
# coroutines
g
You can use non-blocking network API, such as Java.nio
a
And then i can use common pool?
Also is there a doc that explains how to convert blocking code to suspending functions?
m
That’s a very large topic. I would suggest using an existing library that does what you need in a non blocking way.
If there’s no non-blocking library for what you need, you’re probably better off just using a thread pool and blocking i/o unless you really know what you’re doing.
d
@asad.awadia You could try the #ktor client which is built on top of coroutines and is async...
a
Ktor has such poor documentation..
g
Yes, you can use CmonPool or any other dispatcher because the only work of this dispatcher will be process state machine states, no additional work or blocking of threads by IO
Ktor docs are much better now and improving all the time, Kotlin libraries team now has technical writer who work on Ktor
Also is there a doc that explains how to convert blocking code to suspending functions?
INot sure that such documentation exist somewhere, just some advices. It's actually the same as using threads for blocking code, but with coroutines API