Skip to content

23 · Concurrency

Named parallel results

Named tasks in parallel produce a typed result record after the structured join. Every task captures the outer scope; task labels are not variables for siblings. Failure cancels and drains siblings cooperatively. Transitively linear result payloads are rejected.

On this page

Named tasks in parallel produce a typed result record after the structured join. Every task captures the outer scope; task labels are not variables for siblings. Failure cancels and drains siblings cooperatively. Transitively linear result payloads are rejected.

Complete example

Run this example locally with the installed CLI. The browser playground does not provide the host scheduler.

Named parallel results.

16-named-parallel-results.zolo
// Feature: typed named results from structured parallel tasks

// Each label names a result field; each RHS captures only the outer scope.

struct User { name: str }
async fn load_user() -> User = User { name: "Ada" }
async fn load_orders() -> [int] = [101, 102]

let user = "outer"
let data = parallel {
    user = await load_user()
    orders = await load_orders()
    captured = user
}
print(data.user.name)
print(data.orders.len())
print(data.captured)
print(user)
// expected:

//   Ada

//   2

//   outer

//   outer

Requires the Zolo CLI/host — open in the playground or run locally.

Rules and behavior

Parallel tasks and deadlines · Documentation

From a checkout of the repository:

zolo examples/features/16-concurrency/16-named-parallel-results.zolo

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br