func parallel_run<A, T>(
consume jobs: [A],
worker: (consume A) '[io, alloc, yield, panic, wait] -> T
) -> [T] where A: Send && T: SendRun every job on its own parallel worker and return the outputs in argument order (ADR 0058). Structured: every worker completes before this returns, and no handle escapes. Transfer capabilities gate the boundary: jobs move to workers and outputs move back. Each worker gets its own standard host fallbacks; user-defined effects still need handlers inside the worker.
View Source
pub func parallel_run<A, T>(
consume jobs: [A],
worker: (consume A) '[io, alloc, yield, panic, wait] -> T
) -> [T] where A: Send && T: Send {
let handles: [Int] = []
let feed = jobs.into_iter()
loop {
if let .some(job) = feed.next() {
handles.push(_spawn_parallel_worker(job: job, worker: worker))
} else {
break
}
}
let outputs: [T] = []
let joined = handles.into_iter()
loop {
if let .some(handle) = joined.next() {
outputs.push(_task_join<T>(handle: handle))
} else {
break
}
}
outputs
}