runAsync
inline suspend fun <T : Any> Context.runAsync(name: String = "", retryPolicy: RetryPolicy? = null, noinline 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