elizarov
06/27/2018, 4:41 PMEventLoop
. You can use it, but it makes sense only if you process event from this event loop which is a blocking operation. That is what runBlocking
does. It creates EventLoop
for the current thread and then spins on this event loop, waiting for completion. You can take a look at internals of runBlocking
to see what happens there. It is possible to decouple creating event loop from the actual blocking, so in a sense it is possible to have async(EventLoop()) { ... }.runBlocking()
if you define the corresponding .runBlocking()
extension. However, this code reads really ugly and in a backwards way, so I strongly suggest doing it as runBlocking { ... }
, which already works.