use rayon::prelude::*;
use std::path::PathBuf;
use std::sync::Arc;
use super::repo_info::RepoInfo;
use super::worker::Worker;
pub fn get_repos_info_parallel(paths: &[PathBuf]) -> Vec<RepoInfo> {
paths
.par_iter()
.filter_map(|path| RepoInfo::from_path(path.clone()).ok())
.collect()
}
pub type RepoInfoWorker = Worker<PathBuf, RepoInfo>;
impl RepoInfoWorker {
pub fn for_repo_info() -> Self {
Self::new(RepoInfo::from_path)
}
pub fn submit_repos(self: &Arc<Self>, paths: &[PathBuf]) {
for path in paths {
let _ = self.submit(path.clone());
}
self.finish_submitting();
}
}