LEARN VOID / CONCURRENCY
Async & await
Start work with async functions and await their results.
Complete program for the explicit async host adapter. The result below is the returned integer.
async func ticket_total(ticket_count: i32) -> i32:
return ticket_count * 12
async func entry(ticket_count: i32) -> i32:
var pending_total = ticket_total(ticket_count)
var booking_fee = 3
var tickets = await pending_total
return tickets + booking_feeCreate a task before awaiting
Calling ticket_total queues the multiplication and returns an inferred task handle; its body does not run inline. The parent can prepare a booking fee before requesting the result. This example uses arithmetic to show scheduling, without claiming an I/O API.
Use the result when it is ready
await pending_total waits cooperatively for the ticket total. Five tickets at twelve plus a fee of three return 63. Cooperative async does not imply execution on multiple CPU cores; use parallel workers for supported independent CPU work.
Use the explicit async adapter
This is complete source for the explicit async host adapter. The ordinary synchronous CLI entry adapter does not execute async entry functions. Await is supported inside async functions; task handles have no public user-written type spelling. Async function values and async value-receiver methods remain outside the current subset. Public builds are not yet available.