diff --git a/Source/Fn/Binary/Command/Parallel.rs b/Source/Fn/Binary/Command/Parallel.rs index beb944a..49f3b66 100644 --- a/Source/Fn/Binary/Command/Parallel.rs +++ b/Source/Fn/Binary/Command/Parallel.rs @@ -43,18 +43,13 @@ pub async fn Fn(Option { Entry, Separator, Pattern, Command, .. }: Option) { .collect::>(); let Pool = Arc::new(rayon::ThreadPoolBuilder::new().build().expect("Cannot build.")); - let Semaphore = Arc::new(tokio::sync::Semaphore::new(num_cpus::get())); - futures::future::join_all(Entry.into_iter().map(|Entry| { + Entry.into_par_iter().for_each(|Entry| { let Command = Command.clone(); let Approval = Approval.clone(); - let Semaphore = Arc::clone(&Semaphore); - let Pool = Arc::clone(&Pool); - tokio::spawn(async move { - let _Permit = Semaphore.acquire().await.expect("Cannot acquire."); - - if let Err(_) = Approval.send(Pool.install(|| { + Pool.spawn(move || { + let Output = tokio::runtime::Runtime::new().unwrap().block_on(async move { let mut Output = Vec::new(); for Command in &Command { @@ -65,20 +60,17 @@ pub async fn Fn(Option { Entry, Separator, Pattern, Command, .. }: Option) { drop(Lock); } - Output.push(tokio::task::block_in_place(|| { - tokio::runtime::Runtime::new() - .expect("Cannot Runtime.") - .block_on(Process::Fn(&Command, &Entry)) - })); + Output.push(Process::Fn(&Command, &Entry).await); } Output - })) { + }); + + if let Err(_) = Approval.send(Output) { eprintln!("Cannot send."); } - }) - })) - .await; + }); + }); drop(Approval); diff --git a/Target/release/Inn.exe b/Target/release/Inn.exe index d177253..82d333e 100644 Binary files a/Target/release/Inn.exe and b/Target/release/Inn.exe differ diff --git a/Target/release/InnKeeper.exe b/Target/release/InnKeeper.exe index ca903e1..ae6546a 100644 Binary files a/Target/release/InnKeeper.exe and b/Target/release/InnKeeper.exe differ diff --git a/Target/release/PRun.exe b/Target/release/PRun.exe index 6e3d5eb..a18896a 100644 Binary files a/Target/release/PRun.exe and b/Target/release/PRun.exe differ diff --git a/Target/release/Run.exe b/Target/release/Run.exe index dfb0480..5975fe0 100644 Binary files a/Target/release/Run.exe and b/Target/release/Run.exe differ