aboutsummaryrefslogtreecommitdiff
path: root/src/sync
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2022-06-07 12:28:18 +0200
committerMaximilian Manz <maximilian.manz@de.clara.net>2022-06-20 11:33:04 +0200
commit7e73ebcad03a5477367763d4a5e9c22f9e9967ca (patch)
tree39e543ec482be2e95c512b45f6dbdbe816dc0992 /src/sync
parentfix clippy lints (diff)
process sync and update in parallel
Split the repos up in x batches where x is either decided on based on number of cpu cores available or given by the --jobs argument
Diffstat (limited to 'src/sync')
-rw-r--r--src/sync/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sync/mod.rs b/src/sync/mod.rs
index 6cf1f7f..4bfe322 100644
--- a/src/sync/mod.rs
+++ b/src/sync/mod.rs
@@ -1,17 +1,18 @@
use std::fmt::{Debug, Display};
-use crate::repo::{Repo, RepoError, Repos};
+use crate::{
+ batch::batch,
+ repo::{Repo, RepoError, Repos},
+};
impl crate::GTree {
pub fn sync(&self, repos: Repos) {
- for (_name, repo) in repos {
- let mut repo = repo.write().unwrap();
-
+ batch(repos, |mut repo| {
match repo.sync() {
Ok(u) => println!("{}", u),
Err(u) => println!("{}", u),
};
- }
+ });
}
}