diff --git a/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt b/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt index dcaceb2295..0f62fd752f 100644 --- a/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt +++ b/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt @@ -27,6 +27,12 @@ fun CordaFuture.thenMatch(success: (V) -> W, failure: (Throwabl /** When this future is done and the outcome is failure, log the throwable. */ fun CordaFuture<*>.andForget(log: Logger) = thenMatch({}, { log.error("Background task failed:", it) }) +/** + * Returns a future that will also apply the passed closure when it completes. + * + * @param accept A function to execute when completing the original future. + * @return A future returning the same result as the original future that this function was executed on. + */ fun CordaFuture.doOnComplete(accept: (RESULT) -> Unit): CordaFuture { return CordaFutureImpl().also { result -> thenMatch({