|
|
@ -1,6 +1,5 @@
|
|
|
|
use anyhow::{anyhow, bail, Context, Result};
|
|
|
|
use anyhow::{anyhow, bail, Context, Result};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::fs;
|
|
|
|
|
|
|
|
use std::time::SystemTime;
|
|
|
|
use std::time::SystemTime;
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
|
collections::HashSet,
|
|
|
|
collections::HashSet,
|
|
|
@ -8,6 +7,7 @@ use std::{
|
|
|
|
process::Command,
|
|
|
|
process::Command,
|
|
|
|
sync::mpsc::channel,
|
|
|
|
sync::mpsc::channel,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
use std::{fs, thread};
|
|
|
|
use tempfile::TempPath;
|
|
|
|
use tempfile::TempPath;
|
|
|
|
use tree_sitter::Language;
|
|
|
|
use tree_sitter::Language;
|
|
|
|
|
|
|
|
|
|
|
@ -225,25 +225,28 @@ where
|
|
|
|
F: Fn(GrammarConfiguration) -> Result<Res> + Send + 'static + Clone,
|
|
|
|
F: Fn(GrammarConfiguration) -> Result<Res> + Send + 'static + Clone,
|
|
|
|
Res: Send + 'static,
|
|
|
|
Res: Send + 'static,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let pool = threadpool::Builder::new().build();
|
|
|
|
|
|
|
|
let (tx, rx) = channel();
|
|
|
|
let (tx, rx) = channel();
|
|
|
|
|
|
|
|
let mut handles = Vec::new();
|
|
|
|
|
|
|
|
|
|
|
|
for grammar in grammars {
|
|
|
|
for grammar in grammars {
|
|
|
|
let tx = tx.clone();
|
|
|
|
let tx = tx.to_owned();
|
|
|
|
let job = job.clone();
|
|
|
|
let job = job.to_owned();
|
|
|
|
|
|
|
|
|
|
|
|
pool.execute(move || {
|
|
|
|
let handle = thread::spawn(move || {
|
|
|
|
// Ignore any SendErrors, if any job in another thread has encountered an
|
|
|
|
let result = (grammar.grammar_id.to_owned(), job(grammar));
|
|
|
|
// error the Receiver will be closed causing this send to fail.
|
|
|
|
let _ = tx.send(result);
|
|
|
|
let _ = tx.send((grammar.grammar_id.clone(), job(grammar)));
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handles.push(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drop(tx);
|
|
|
|
for handle in handles {
|
|
|
|
|
|
|
|
handle.join().unwrap();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drop(tx);
|
|
|
|
rx.iter().collect()
|
|
|
|
rx.iter().collect()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum FetchStatus {
|
|
|
|
enum FetchStatus {
|
|
|
|
GitUpToDate,
|
|
|
|
GitUpToDate,
|
|
|
|
GitUpdated { revision: String },
|
|
|
|
GitUpdated { revision: String },
|
|
|
|