Coroutines make using nio simpler. For blocking io they provide little benefit as they will need one thread per io channel anyway
d
Dexter
04/21/2018, 4:24 AM
@uli So I assumed that a coroutine blocked on (a blocking read or write) will suspend allowing other coroutines on the same thread to be dispatched.
Let’s say I had one suspend coroutine doing blocking I/O and a bunch of other coroutines on the same performing some sort of compute, are you saying that the compute coroutines will not be dispatched?
Dexter
04/21/2018, 9:43 AM
Got it. So just for clarification, if I made a blocking I/O call my whole thread and all associated coroutines on that thread will block on the I/O? That is assuming that my coroutines are not using a context with an underlying thread pool. I think I got this all wrong.
u
uli
04/21/2018, 10:16 AM
Exactly
uli
04/21/2018, 10:17 AM
Same Ist true for long running computations
uli
04/21/2018, 10:17 AM
And instead of a blocking sleep you have delay to suspend for a while
uli
04/21/2018, 10:18 AM
Basically you want no blocking in your coroutines or at least put the blocking on a context with separate threads