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

evan

12/13/2017, 5:05 PM
Would you say
launch
is a
CoroutineBuilder
designed to work similar to a threads behavior on Java? They are “fire and forget”, and swallow errors with the caveat that child `Job`s cancel parents with a
Throwable
. While
async
is a
CoroutineBuilder
designed to work like C#’s async/await, and expects a value returned, even if its an error similar to java futures with
Deferred
e

elizarov

12/13/2017, 6:23 PM
Yes.
e

evan

12/13/2017, 8:04 PM
If
launch
and
async
are considered essential “base” builders, is there a performance overhead to implement
CompletableFuture
, or other frameworks wrapped in the
suspendedCoroutine
builder? I understand the benefit of converting a blocking callback to a suspending callback, but I don’t realize the cost compared to
launch
and
async
, builders which seem to only denote a preference in error return.
e

elizarov

12/13/2017, 9:22 PM
They are not base builders. Base builder is
startCoroutine
from stdlib. All other builders are implemented on top of it:
launch
,
async
,
futures
, etc are all equally high-level builders. Their impls even follow the same pattern.
👍 2
2 Views