andrea.santurbano
03/27/2019, 8:19 AMFuture
implementation (https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/FutureRecordMetadata.java) as Deferred
. Could this be a solution?
fun <T> Future<T>.asDeferred(): Deferred<T> {
return GlobalScope.async(<http://Dispatchers.IO|Dispatchers.IO>) {
get()
}
}
@rocketraman suggested to follow also this solution: https://stackoverflow.com/questions/50793362/how-to-use-suspendcoroutine-to-turn-java-7-future-into-kotlin-suspending-functio#answer-52901712
Which of these two is the most correct?hmole
03/27/2019, 8:35 AMCompletableFuture
and use coroutine jdk8 wrappersandrea.santurbano
03/27/2019, 9:42 AMrocketraman
03/27/2019, 12:16 PMFuture
in CompletableFuture
doesn't solve the underlying problem... whenever and wherever that get
is called, its gonna block. That's why I suggested he use the IO dispatcher for the get
.