how can they executes 100000 sleeps(1sec) in a thread pool and the whole result only takes a bit more than 1 sec?!!?
what kind of magic lays behind that!? 😱
r
ross_a
05/22/2017, 8:52 AM
mingkangpan: The key point is they are using
delay
which is suspendable - NOT `sleep`… Using sleep would still block each thread
You still have to use caution when introducing blocking code, rather than suspendable code, into coroutines
m
mingkangpan
05/22/2017, 8:59 AM
yeah I realised afterwards too, suspending is not blocking
do you think you can also execute 100k io bounded requests parallel? r.g. suspending 100k http requests?
r
ross_a
05/22/2017, 9:30 AM
yes I recon so
I was at a Vert.x talk the other day where the guys mentioned they are going to be adding Kotlin Coroutine wrappers quite soon