runAsync
abstract suspend fun <T> runAsync(typeTag: TypeTag<T>, name: String = "", retryPolicy: RetryPolicy? = null, block: suspend () -> T): DurableFuture<T>
Execute a closure asynchronously. This is like runBlock, but it returns a DurableFuture that you can combine and select.
// Fan out the subtasks - run them in parallel
val futures = subTasks.map { subTask ->
ctx.runAsync { subTask.execute() }
}
// Fan in - Await all results and aggregate
val results = futures.awaitAll()
Content copied to clipboard