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

AsyncRun

Executes the given code asynchronously and returns to you a BoxFuture object which inherits from CompletableFuture.

This way you can create fluent asynchronous code that can be chained and composed.

Method Signature

AsyncRun(callback=[function], executor=[any])

Arguments

Argument
Type
Required
Description
Default

callback

function

true

The code to execute asynchronously, this can be a closure or lambda.

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

Execute code asynchronously

Runs the callback in a separate thread and returns a BoxFuture.

future = asyncRun( () => sleep( 100 ) && return "done" );
writeOutput( future.get() );

Result: done

Chain async operations with then()

Result: 25

Using the runAsync() alias

Result: hello from async

Last updated

Was this helpful?