Skip to main content

with_threads

Function with_threads 

Source
pub fn with_threads<R: Send>(
    threads: Option<usize>,
    f: impl FnOnce() -> R + Send,
) -> R
Expand description

f を threads 本のスレッドで実行する。None は既定(外の指定を引き継ぐ: with_threads(Some(1), ..) の中なら逐次、 別の with_threads のプールの中ならそのプール。どちらでもなければ [set_default_threads] の数があればその数、 なければ rayon の大域プールで RAYON_NUM_THREADS が効く)、 Some(1) は呼び出したスレッドで逐次、Some(0) は外の逐次の指定を外して既定に戻す。 Some(n)(n ≥ 2)のプールは n ごとに作って使い回し、解放しない。