For working non blocking the AWS2 SDK provides methods which returns CompleteableFuture<T>. Wrapping them into coroutines I wrote the following extension function (I don't like the name). My question would be, is that extension okay, or even already implemented in the standard coroutines library?
If that extension is okay, what would you suggest as name for it?
Copy code
suspend fun <T> CompletableFuture<T>.suspending() : T = suspendCoroutine { cont ->
whenComplete { v, e -> if(e==null) cont.resume(v) else cont.resumeWithException(e) }
}
It can be used for example to wrap the following AWS SDK method: