LEARN VOID / CONCURRENCY

Parallel workers

Move independent work onto bounded native workers.

Complete program for the explicit async host adapter. The result below is the returned integer.

parallelism.voidDownload source
func sum_squares(limit: i32) -> i32:
    var total = 0
    var number = 1
    for number <= limit:
        total += number * number
        number += 1
    return total

async func entry(limit: i32) -> i32:
    var calculation = spawn sum_squares(limit)
    return await calculation
Input 5Expected result 55

Keep the worker calculation independent

sum_squares adds the squares of integers from one through the limit. It has a scalar input, scalar result and private locals. Input 5 calculates 1 + 4 + 9 + 16 + 25 = 55.

Submit and await one job

spawn sum_squares(limit) submits the synchronous function to a bounded native worker. The async parent awaits the answer. This makes the transfer boundary visible without introducing shared state or combining several unrelated worker tests.

Respect supported transfers

The current subset requires directly named synchronous noncapturing functions and supported value transfers. Managed mutable objects, lists, dictionaries, interfaces, task handles, callable values and native resources cannot be passed across this boundary. The full program requires the explicit async host adapter; ordinary CLI execution does not select it.