← ClaudeAtlas

boxlang-async-programminglisted

Use this skill when writing BoxLang asynchronous code: BoxFuture, futureNew, asyncRun, asyncAll, asyncAny, asyncAllApply, executors, schedulers, thread components, parallel pipelines, file watchers, or distributed locking with bx:lock.
ortus-boxlang/skills · ★ 0 · Data & Documents · score 58
Install: claude install-skill ortus-boxlang/skills
# BoxLang Async Programming ## Overview BoxLang provides a comprehensive async framework built on Java's CompletableFuture and Project Loom virtual threads. The `AsyncService` manages executors, schedulers, and futures. All async primitives integrate seamlessly with the BoxLang runtime. ## Creating BoxFutures `BoxFuture` extends `CompletableFuture` with BoxLang-friendly chaining. ### `futureNew()` — Primary BIF (v1.4.0+) ```boxlang // Create a future from a function (runs asynchronously) var future = futureNew( () => fetchDataFromAPI() ) // Create a completed future with a value var future = futureNew( "Hello World" ) // Create an empty future (complete later) var future = futureNew() // Create with a specific executor var future = futureNew( () => heavyCalculation(), "cpu-tasks" ) ``` ### `asyncRun()` — Simplified Async Execution ```boxlang // Run a function asynchronously on the default io-tasks executor var future = asyncRun( () => fetchDataFromAPI() ) // Run with specific executor var future = asyncRun( () => processCPUWork(), "cpu-tasks" ) // Get the result (blocks until complete) var result = future.get() // With timeout var result = future.get( 5, "seconds" ) ``` ## Chaining with `then`, `thenAsync`, and `onError` - `then()` — runs the transformation on the **same thread** (fast, lightweight transforms) - `thenAsync()` — runs the transformation on an **executor thread** (for heavy/I/O work) ```boxlang asyncRun( () => fetchUser( userId ) ) .then( (u