Skip to main content

apply_thread_cap

Function apply_thread_cap 

Source
pub fn apply_thread_cap(n: usize) -> usize
Expand description

Pre-warm the throttle pool for a thread cap. Returns the live worker count.

Phase 2 (race-to-idle) changed the model. The global rayon pool is left at its default (all cores) so that bursts can use full parallelism; the thermal cap is enforced per-operation by run_parallel, which installs sustained work into a smaller, cached pool. This call just pre-builds that capped pool so the first sustained op doesn’t pay the build cost. n == 0 or n >= cores means “no cap” and builds nothing.