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🔗

FunctionSignatureDescription
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/await as language keywords are not yet implemented. Coroutine support is available through the dogma:async stdlib package and the host's with_async() configuration.