dogma:async
import { await_all } from "dogma:async"
Dogma supports coroutine-based concurrency. The host must enable it with Engine::builder().with_async(). See Engine Builder.
Functions🔗
| Function | Signature | Description |
|---|---|---|
await_all | (coroutines: [i32]) -> [i32] | Wait for all coroutines to complete, return results |
await_all is the equivalent of Promise.all — it runs all coroutines concurrently and returns when all have finished.
Example🔗
import { await_all } from "dogma:async"
import { println } from "dogma:core"
fn fetch(url: String) -> i32 {
// returns a coroutine handle
}
fn main() {
let handles = [fetch("https://a.example"), fetch("https://b.example")]
let results = await_all(handles)
println(f"Got {results.len()} responses")
}
Note:
async/awaitas language keywords are not yet implemented. Coroutine support is available through thedogma:asyncstdlib package and the host'swith_async()configuration.