Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Support rayon #4

Open
udalrich opened this issue Oct 11, 2021 · 0 comments
Open

Support rayon #4

udalrich opened this issue Oct 11, 2021 · 0 comments

Comments

@udalrich
Copy link

It does not seem to be possible to use progressive with rayon's par_iter. I would like to do something like

use progressive::progress;
use rayon::prelude::*;
use std::{thread, time};
fn main() {
    let v: Vec<u64> = (0..10).collect();

    progress(
        v.par_iter()
            .map(|n| time::Duration::from_secs(n.to_owned()))
            .inspect(|n| {
                thread::sleep(n.to_owned());
            }),
    )
    .for_each(|n| {
        println!("Slept {:?}", n);
    });

    println!("Results:")
}

but that does not compile because par_iter and the related functions do not return an Iterator.

Ideally, the above code would produce a progress bar that updates once a second, going from 0 to 11 units of work completed.

I am not familiar with the details of how rayon works, so this is probably at least more complicated than supporting Iterator and could easily be very difficult/impossible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant