pub async fn run_pool<'a, G: PowGenerator + ?Sized>(
generator: &'a G,
label: &'a str,
iteration_cap: Option<usize>,
pow_min: Pow,
data_hash: Hash,
) -> Result<(Salt, Pow, Hash)>Expand description
Work-stealing dispatcher shared by both generate and generate_best_effort.
Algorithm:
- Register the job in the tracker (RAII so panic / cancel still cleans up).
- Initial fill: push one chunk onto each of
pool_size()slots, clamped byiteration_capwhen bounded. - As each chunk completes, merge its best result. If
pow_minis met, return immediately — theFuturesUnorderedis dropped, discarding any in-flight chunks (the underlying worker / blocking thread continues silently and its result is lost). - Otherwise, update the tracker / progress estimator, cooperatively yield, and refeed only the slot that just freed up. Fast slots end up processing more chunks than slow ones — no idle waiting on the slowest core.