pub fn parallel_for_each<I, F, T>(gate: RuntimeGate, tasks: I) -> Vec<Option<T>>Expand description
Runs each closure in tasks on its own fiber and waits for all of them
to finish before returning. Closures produce a T which is collected
into the returned Vec in input order.
Panics inside individual tasks are caught via std::panic::catch_unwind
and mapped to None in the output; the returned Vec contains all slots
including None values for panicking tasks, preserving input order.
Uses a lock-free write path: each fiber writes directly into its own
pre-allocated slot in an UnsafeCell<Vec<Option<T>>> using the slot
index as the exclusive key — no Mutex contention between workers.
The fan-in join barrier (dtact_await) provides the happens-before
edge that makes the final read of all slots safe.
This is the workhorse used by parallel::solver and ffi::async_bridge
to replace the std::thread::spawn pattern.