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

Dexter

04/20/2018, 6:33 PM
I need to ramp up quickly on idiomatic Kotlin patterns using coroutines with both blocking and non-blocking I/O. Does anyone have any substantial experience in this area? In particular, I will like to know how suspend fuctions with blocking network I/O performs against non-suspend functions using NIO.
c

Caleb Allen

04/20/2018, 6:40 PM
https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md this document is your goldmine. It will provide you with the concepts to handle blocking or nonblocking I/O. I'm not aware of any resources specifically for the use case but the concepts will be the same
l

louiscad

04/20/2018, 6:49 PM
There's a kotlinx.coroutines artifact for nio
d

Dexter

04/20/2018, 11:26 PM
@Caleb Allen and @louiscad Thank you for your responses. I looked at the Kotlin artifact for nio before and did not think it was rich as I expected. Maybe I was too quick in my judgement and will take a look again. Thanks for the pointer https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md. I will also look at this again.
g

groostav

04/20/2018, 11:42 PM
@Dexter
nio
is pretty large, are you dealing with files? protocol specific sockets? rest-ful port-80 business?
d

Dexter

04/20/2018, 11:48 PM
@groostav All the above. I am writing a streaming product. To scale and perform all its component should be asynchronous and/or non-blocking. Kotlin's suspend coroutines with blocking I/O is tempting from an ease of use perspective but I wonder about performance. Do you know if anyone has benchmarked the two approaches?
21 Views