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