poohbar
01/01/2019, 4:22 PMrunBlocking
is a bridge between the coroutine "world" and normal non-coroutine "world". Are there any other "bridges"? I am looking for runNonBlocking
.bdawg.io
01/01/2019, 4:52 PMCompletableFuture
via the kotlinx-coroutines-jdk8
module val myFuture = future<Int> {
delay(100)
100
}
Note: the coroutine APIs, including launch
, spend a lot of time ensuring deep cancellation and handled failures. They’re definitely my go-to over futures.poohbar
01/01/2019, 8:25 PMdave08
01/02/2019, 3:47 AMasync {}
is also another bridge when you need the result (or to bubble up an exception thrown, since launch will just "swallow" the exception...), just learn about structured concurrency before you start with them, so you don't leak your coroutines.