Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment scatter

std/flow/scatter::scatter


Generics

◻ T (any)
◻ S (any)

Configuration

⬡ scatter: std/flow/scatter::Scatter

Parameters

↳ var parallel: u32 = 8

Inputs

⇥ shared: Block<S>
⇥ values: Stream<T>

Outputs

↦ completed: Block<void>
↦ errors: Stream<string>
↦ failed: Block<void>
↦ finished: Block<void>


Scatter values over tracks of their own.

For each value received through values, a track is made where scattered gives it, with the value received through shared (a trigger when nothing is shared), at most parallel at once: values is not read further until one ends, a track ending when it tells gather how, even if some of its treatments still finish. Tracks start in the order of values, and end in any order, each telling how through gather. They get the contexts of the track of scatter, with @Scattered.

Once values ends and every track ended, finished is emitted, and completed if they all completed. If one failed, or ended without gathering, failed is emitted and errors gives why. scattered<T, S> must be used with the same types and the same Scatter.

graph LR
     T("scatter()")
     V["… 🟦 🟦 🟦"] -->|values| T
     S["〈🟨〉"] -->|shared| T

     T -.->|"track per 🟦"| X["scattered() … gather()"]
     T -->|completed| C["〈🟩〉"]

     style V fill:#ffffff,stroke:#ffffff
     style S fill:#ffffff,stroke:#ffffff
     style X fill:#ffffff,stroke:#ffffff
     style C fill:#ffffff,stroke:#ffffff