https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

Sam Garfinkel

03/24/2020, 6:27 PM
I’m sure this should be obvious, but given an existing synchronous API that expects a blocking
InputStream
or
Reader
, what’s the correct way to wrap that such that I can call it as a suspendable function and map some sort of asynchronous communication such as a
Channel
into the given
InputStream
?
Should I wrap the blocking io in
with(<http://Dispatchers.IO|Dispatchers.IO>) { … }
then how to I map the asynchronous channel into a synchronous data structure?
k

kevin.cianfarini

03/24/2020, 6:31 PM
For the time being, you should offload blocking IO to Dispatchers IO like above
however, you should watch this repo closely.
At some point in the future, it will support non blocking IO
s

Sam Garfinkel

03/24/2020, 6:58 PM
Cool, thanks!
2 Views