diff --git a/Cargo.lock b/Cargo.lock index 13c1ea333..c34835fcb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml index d15d87f95..ef7667c33 100644 --- a/helix-loader/Cargo.toml +++ b/helix-loader/Cargo.toml @@ -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" diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs index 7977c6df8..092985866 100644 --- a/helix-loader/src/grammar.rs +++ b/helix-loader/src/grammar.rs @@ -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 + 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 },