For the complete documentation index, see llms.txt. This page is also available as Markdown.

AsyncAny

This BIF accepts an array of futures/closures/lambdas and executes them all in parallel, returning a BoxFuture that will contain the result of the first future that completes successfully.

Method Signature

AsyncAny(futures=[array], executor=[any])

Arguments

Argument
Type
Required
Description
Default

futures

array

true

An array of BoxFuture objects to process in parallel

executor

any

false

The executor to use for the asynchronous execution. This can be an instance of an Executor class, or the name of a registered executor in the AsyncService.

Examples

Return the first future to complete

Executes all futures in parallel and returns the result of the fastest one.

slow = asyncRun( () => sleep( 200 ) && return "slow" );
fast = asyncRun( () => sleep( 50 ) && return "fast" );
result = anyOf( [ slow, fast ] ).get();
writeOutput( result );

Result: fast

Race multiple computations

Result: B

Last updated

Was this helpful?