mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-09-20 00:06:52 +08:00
add concurrent thread config
This commit is contained in:
@@ -16,5 +16,6 @@ pub struct Profile {
|
||||
#[serde(flatten)]
|
||||
pub sync_context: SyncContext,
|
||||
pub path: String,
|
||||
pub interval: Option<u64>
|
||||
pub interval: Option<u64>,
|
||||
pub concurrent: Option<usize>,
|
||||
}
|
||||
|
||||
+15
-2
@@ -29,6 +29,7 @@ pub async fn run(
|
||||
.await?,
|
||||
);
|
||||
let manifest_snapshot = { local_manifest.manifest.read().await.clone() };
|
||||
let all_cnt = sync_resp.tasks.len();
|
||||
let tasks = sync_resp
|
||||
.tasks
|
||||
.into_iter()
|
||||
@@ -40,8 +41,20 @@ pub async fn run(
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
info!("[{}]: Collected {} tasks", profile.0, tasks.len());
|
||||
let n = 5;
|
||||
info!(
|
||||
"[{}]: Collected {}/{} tasks",
|
||||
profile.0,
|
||||
tasks.len(),
|
||||
all_cnt
|
||||
);
|
||||
if tasks.is_empty() {
|
||||
info!("[{}]: No tasks to sync, skipping", profile.0);
|
||||
let req = CloseRequest { id: id.clone() };
|
||||
close(&mut client.get_client().await?, &req).await?;
|
||||
return Ok(true);
|
||||
}
|
||||
let n = profile.1.concurrent.unwrap_or(5);
|
||||
info!("[{}]: Start sync with {} thread", profile.0, n);
|
||||
let semaphore = Arc::new(Semaphore::new(n));
|
||||
let mut join_set = JoinSet::new();
|
||||
for task in tasks {
|
||||
|
||||
Reference in New Issue
Block a user