Coroutines and blocking I/O on an event loop in Vert.x


If I have blocking I/O in Java-code (storage system) and I want to not block an event loop used for processing each HTTP-Request (as in Node.JS), is it okay to dispatch the coroutines on this thread (I guess the thread just can be used for other stuff while the OS fetches bytes from disk or better a flash drive)? I think when the I/O is made, the coroutine is going to be suspended and the thread can be reused for processing other requests, when I’m calling it with withContext(SingleThreadDispatcher from Vert.x) { … } while the I/O is made and it gets resumed afterwards, doing the stuff which follows sequentially. Once I’m going to store or execute a query (which might both be a longer running CPU as well as blocking I/O task) it’s done via another dispatcher.

Hope my understanding of coroutines / suspendable functions is right.

But in any case if someone wants to take a quick peek, I would be more than happy about any kind of suggestions for a simple RESTful-API for a temporal storage system[1], especially regarding idiomatic Kotlin code and the right usage of coroutines.

[1] or