rayon-rs / rayon

Rayon: A data parallelism library for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a broadcast that only gets executed on idle threads

sarah-ek opened this issue · comments

this would be useful for code that needs a known number of threads before entering the parallel region, though im not sure how feasible it is to implement in rayon

example user code could look like this

rayon::broadcast_idle(|num_threads, broadcast| {
    let barrier = std::sync::Barrier::new(num_threads);
    broadcast.run(|ctx| {
        // run task on each thread

        // synchronize
        barrier.wait();
    });
});