Prior to this commit there was no support for converting Kotlin coroutines to/from ListenableFuture. Following that change a number of functions will be available for such conversion.
Specifically these functions are introduced:
-
// for converting suspending lambda to ListenableFuture
fun <T> listenableFuture(context: CoroutineContext = CommonPool, block: suspend () -> T): ListenableFuture<T>
-
// for converting Deffered into ListenableFuture
fun <T> Deferred<T>.asListenableFuture(): ListenableFuture<T>
-
// for converting ListenableFuture into suspending function
suspend fun <T> ListenableFuture<T>.await(): T
The code in this PR draws heavily on the code from https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-jdk8/src/main/kotlin/kotlinx/coroutines/experimental/future/Future.kt. This is why Roman Elizarov is also an author.
Comment From: enleur
Just to have a reference to the issue https://jira.spring.io/browse/SPR-15413
Comment From: snicoll
@sdeleuze can you please check if this is still applicable?
Comment From: poutsma
After team discussion, we have decided not to invest in ListenableFuture
. It can easily be converted into a CompletableFuture
, which has Kotlin support through kotlinx-coroutines-jdk8
.
Thank you for submitting a PR, though.
Comment From: rstoyanchev
Also see #27780.
Comment From: sdeleuze
+1 for that decision.