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

mp

08/05/2018, 10:53 PM
Are there established ways to convert various flavors of future (beyond
CompletionStage.asDeferred()
) into
Deferred
for use in
suspend
functions? If not, I can always adapt code from
asDeferred
, but if there’s something supported out there, might as well use it
g

gildor

08/06/2018, 1:53 AM
There are a bunch of coroutines adapters for different kinds of futures/promises. I don’t see any problem to convert any future to Deferred or, even better to just suspend function:
yourFuture.await()
Unfortunately this example doesn’t cover cancellation case
m

mp

08/06/2018, 3:07 AM
Hm, interesting. Perhaps adding
await()
as you suggest is the way to go.
3 Views