Library/Fn/Binary/Command/
Parallel.rs1pub async fn Fn(Option { Entry, Separator, Pattern, Omit, .. }:Option) {
37 let (Allow, mut Mark) = tokio::sync::mpsc::unbounded_channel();
38
39 let Queue = futures::stream::FuturesUnordered::new();
40
41 for Entry in Entry
42 .into_par_iter()
43 .filter_map(|Entry| {
44 Entry
45 .last()
46 .filter(|Last| *Last == &Pattern)
47 .map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string()))
48 })
49 .collect::<Vec<String>>()
50 {
51 let Omit = Omit.clone();
52
53 let Allow = Allow.clone();
54
55 Queue.push(tokio::spawn(async move {
56 match crate::Fn::Summary::Fn(&Entry, &crate::Struct::Summary::Difference::Struct { Omit }).await {
57 Ok(Summary) => {
58 if let Err(_Error) = Allow.send((Entry, Summary)) {
59 eprintln!("Cannot Allow: {}", _Error);
60 }
61 },
62
63 Err(_Error) => {
64 eprintln!("Cannot Summary for {}: {}", Entry, _Error)
65 },
66 }
67 }));
68 }
69
70 tokio::spawn(async move {
71 Queue.collect::<Vec<_>>().await;
72
73 drop(Allow);
74 });
75
76 let mut Output = Vec::new();
77
78 while let Some((Entry, Summary)) = Mark.recv().await {
79 Output.push((Entry, Summary));
80 }
81
82 crate::Fn::Summary::Group::Fn(Output);
83}
84
85use futures::stream::StreamExt;
86use rayon::iter::{IntoParallelIterator, ParallelIterator};
87
88use crate::Struct::Binary::Command::Entry::Struct as Option;