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

Support rayon #4

Description

@udalrich

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions