Closed
Description
Konrad Kamiński opened SPR-15413 and commented
Since 1.1
Kotlin supports coroutines. Its library support includes utility functions for converting suspending functions/lambdas to/from CompletableFuture / Deferred. It would be nice to have such support ListenableFuture as well.
The API could look as follows:
// a function for creating ListenableFuture from suspending lambda
fun <T> listenableFuture(context: CoroutineContext = CommonPool, block: suspend () -> T): ListenableFuture<T>
// a function for creating ListenableFuture from Deferred
fun <T> Deferred<T>.asListenableFuture(): ListenableFuture<T>
// an extension suspending function which awaits for ListenableFuture completion
suspend fun <T> ListenableFuture<T>.await(): T
Affects: 5.0 M5
Issue Links:
- Incorrect return type of Kotlin suspending functions [SPR-16515] #21058 Incorrect return type of Kotlin suspending functions
Referenced from: pull request #1375
18 votes, 26 watchers