Rest/Fn/Binary/Command/
Parallel.rs1pub async fn Fn(Option { Entry, Separator, Pattern, .. }:Option) {
42 let (Allow, mut Mark) = tokio::sync::mpsc::unbounded_channel();
43
44 let Queue = futures::stream::FuturesUnordered::new();
45
46 let glob = globset::Glob::new(&Pattern)
47 .expect("Invalid pattern")
48 .compile_matcher();
49
50 for Entry in Entry
51 .into_par_iter()
52 .filter_map(|Entry| {
53 if glob.is_match(&Entry.join(&Separator.to_string())) {
54 Some(Entry[0..Entry.len() - 1].join(&Separator.to_string()))
55 } else {
56 None
57 }
58 })
59 .collect::<Vec<String>>()
60 {
61 let Allow = Allow.clone();
62
63 Queue.push(tokio::spawn(async move {
64 match crate::Fn::Build::Fn(&Entry).await {
65 Ok(Build) => {
66 if let Err(_Error) = Allow.send((Entry, format!("{:?}", Build))) {
67 eprintln!("Cannot Allow: {}", _Error);
68 }
69 },
70
71 Err(_Error) => {
72 eprintln!("Cannot Build for {}: {}", Entry, _Error)
73 },
74 }
75 }));
76 }
77
78 tokio::spawn(async move {
79 Queue.collect::<Vec<_>>().await;
80
81 drop(Allow);
82 });
83
84 let mut Output = Vec::new();
85
86 while let Some((Entry, Build)) = Mark.recv().await {
87 Output.push((Entry, Build));
88 }
89
90 crate::Fn::Build::Group::Fn(Output);
91}
92
93use futures::stream::StreamExt;
94use rayon::iter::{IntoParallelIterator, ParallelIterator};
95
96use crate::Struct::Binary::Command::Entry::Struct as Option;