Expand description
Independent items on a bounded number of threads, reported in input order with no lock. What: Runs independent items on a bounded number of threads and reports what they say and what they return in input order, as if they had run one after another. Why: Items that share nothing (one worktree each, one directory each) need not wait for each other, but a person reads one stream of lines. The calling thread is the only consumer: workers hand it lines and results over a channel, it prints the lines of the first unfinished item as they arrive (so progress stays live), holds the lines of later items until every item before them is complete, and then prints them in order. No lock is taken: the channel and one atomic counter that hands out the lanes are the whole of the sharing, and every item has exactly one owner.
In TS you’d write (pseudocode):
await runOrdered({ items, lanes, workers, work: (index, item, say) => convert(item, say), onEvent });Structs§
- Ordered
Run - What: Everything one ordered run needs. Why: One value names the inputs, so the call reads as a list of facts.
Enums§
- Event
- What: What the consumer is told, always in input order. Why: An item begins when every item before it is complete, says its lines, and ends with its result.
Functions§
- run_
ordered - What: Run every item and report in input order. Why: See the module description. A panic in a worker ends the run: the channel closes when every worker is gone, the consumer stops waiting, and the scope raises the worker’s panic on the calling thread.