LEARN VOID / CONCURRENCY
Parallel workers
Move independent work onto bounded native workers.
This example uses the explicit async host adapter. Its source is checked by the compiler; it is not a synchronous CLI entry program.
func square(number: i32) -> i32:
return number * number
async func entry(number: i32) -> i32:
var first = spawn square(number)
var second = spawn square(number + 1)
return await first + await secondChoose independent work
square is a synchronous function with a scalar argument and result. Each call has its own input and needs no shared mutable state.
Submit work explicitly
spawn submits each calculation to a bounded native worker. The async parent awaits the two results and adds them. With input 5, the calculations are 5² and 6², returning 61. Their completion order does not affect the answer.
Respect the transfer boundary
The current worker subset supports directly named synchronous noncapturing functions and supported value transfers. Arbitrary shared mutable objects, task handles, callable values and native resources are not transferable this way. The program uses the explicit async host adapter, not the ordinary synchronous CLI entry adapter.