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

Felix

04/03/2018, 5:25 PM
The coroutines builders terminology is used to characterise regular functions that take a suspend lambda and return an object representing the asynchronous computations (e.g.
Deferred
or
CompletableFuture
). In my understanding, they convert from the "suspend" world into the "classical world". In this context, is there any terminology to classify the functions (typically extensions functions such as
await
) that do the reverse: convert from the "classical" world into the "suspend" world, i.e., suspend functions receive a representation of an asynchronous computation and return a value?
i

ilya.gorbunov

04/03/2018, 11:36 PM
await
doesn't do the reverse, it is
suspend
too
f

Felix

04/04/2018, 11:52 AM
I may be missing something, but it seems "kind of" a reverse to me. Here is how I see things: - A coroutine builder is a regular function that takes a suspend lambda and returns an object representing the asynchronous outcome. It allows me to extract values from the suspend world as Job/Deferred/CompletableFuture. - A await/aRead/... is a suspend function that takes an object representing an asynchronous (CompletableFuture/Single/Channel ) outcome and returns a value. It allows me to insert values into the suspend world.
3 Views