remove threadpool deps

pull/9932/head
Lee ByeongJun 3 months ago
parent 3d4889ce9a
commit 513946aabd

10
Cargo.lock generated

@ -1302,7 +1302,6 @@ dependencies = [
"once_cell",
"serde",
"tempfile",
"threadpool",
"toml",
"tree-sitter",
]
@ -2270,15 +2269,6 @@ dependencies = [
"syn 2.0.48",
]
[[package]]
name = "threadpool"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
dependencies = [
"num_cpus",
]
[[package]]
name = "time"
version = "0.3.23"

@ -29,7 +29,6 @@ log = "0.4"
# cloning/compiling tree-sitter grammars
cc = { version = "1" }
threadpool = { version = "1.0" }
tempfile = "3.10.1"
dunce = "1.0.4"

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

Loading…
Cancel
Save