Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Sep 30, 2024
1 parent 1c90640 commit 9f09e1e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Source/Fn/Binary/Command/Parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
///
/// This function will log errors if it fails to generate summaries or send results.
pub async fn Fn(Option { Entry, Separator, Pattern, Omit, .. }: Option) {
let (Approval, mut Receipt) = tokio::sync::mpsc::unbounded_channel();
let (Allow, mut Mark) = tokio::sync::mpsc::unbounded_channel();
let Queue = futures::stream::FuturesUnordered::new();

for Entry in Entry
Expand All @@ -43,7 +43,8 @@ pub async fn Fn(Option { Entry, Separator, Pattern, Omit, .. }: Option) {
.collect::<Vec<String>>()
{
let Omit = Omit.clone();
let Approval = Approval.clone();

let Allow = Allow.clone();

Queue.push(tokio::spawn(async move {
match crate::Fn::Summary::Fn(
Expand All @@ -53,23 +54,24 @@ pub async fn Fn(Option { Entry, Separator, Pattern, Omit, .. }: Option) {
.await
{
Ok(Summary) => {
if let Err(_Error) = Approval.send((Entry, Summary)) {
eprintln!("Cannot Approval: {}", _Error);
if let Err(_Error) = Allow.send((Entry, Summary)) {
eprintln!("Cannot Allow: {}", _Error);
}
}

Err(_Error) => eprintln!("Cannot Summary for {}: {}", Entry, _Error),
}
}));
}

tokio::spawn(async move {
Queue.collect::<Vec<_>>().await;
drop(Approval);
drop(Allow);
});

let mut Output = Vec::new();

while let Some((Entry, Summary)) = Receipt.recv().await {
while let Some((Entry, Summary)) = Mark.recv().await {
Output.push((Entry, Summary));
}

Expand Down

0 comments on commit 9f09e1e

Please sign in to comment.