
io.p8e.util.CompletableFutureUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of p8e-common Show documentation
Show all versions of p8e-common Show documentation
A collection of services and libraries that iteract and run Provenance Java based contracts.
The newest version!
package io.p8e.util
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutorService
import kotlin.concurrent.thread
object CompletableFutureUtil {
fun completableFuture(executor: ExecutorService, fn: () -> T): CompletableFuture {
val completableFuture = CompletableFuture()
thread(start = false) {
try {
completableFuture.complete(fn())
} catch(t: Throwable) {
completableFuture.completeExceptionally(t)
}
}.let(executor::submit)
return completableFuture
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy