diff options
author | Blaž Hrastnik | 2021-02-24 04:13:49 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-02-24 04:17:10 +0000 |
commit | c6456d04b9f16ed8f5ad0f256a38218b514de5dc (patch) | |
tree | 63a43d8a0b01cdedb0f51e2be0e9b4816cae092e /helix-syntax | |
parent | 41c0d5828fe301edf3bbc1dbd8fad7adf507e03e (diff) |
syntax: Drop the rayon dependency for threadpool.
We just need a small concurrent threadpool for compilation.
Diffstat (limited to 'helix-syntax')
-rw-r--r-- | helix-syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | helix-syntax/build.rs | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/helix-syntax/Cargo.toml b/helix-syntax/Cargo.toml index 86aaf360..c50e3091 100644 --- a/helix-syntax/Cargo.toml +++ b/helix-syntax/Cargo.toml @@ -11,4 +11,4 @@ tree-sitter = "0.17" [build-dependencies] cc = { version = "1", features = ["parallel"] } -rayon = { version = "1.5" } +threadpool = { version = "1.0" } diff --git a/helix-syntax/build.rs b/helix-syntax/build.rs index 627a0290..89641225 100644 --- a/helix-syntax/build.rs +++ b/helix-syntax/build.rs @@ -1,7 +1,8 @@ -use rayon::prelude::*; use std::path::PathBuf; use std::{env, fs}; +use std::sync::mpsc::channel; + fn get_opt_level() -> u32 { env::var("OPT_LEVEL").unwrap().parse::<u32>().unwrap() } @@ -115,10 +116,25 @@ fn main() { "tree-sitter-cpp".to_string(), ]; let dirs = collect_tree_sitter_dirs(ignore); - dirs.par_iter().for_each(|dir| { - let language = &dir[12..]; // skip tree-sitter- prefix - build_dir(&dir, &language); - }); + + let mut n_jobs = 0; + let pool = threadpool::Builder::new().build(); // by going through the builder, it'll use num_cpus + let (tx, rx) = channel(); + + for dir in dirs { + let tx = tx.clone(); + n_jobs += 1; + + pool.execute(move || { + let language = &dir[12..]; // skip tree-sitter- prefix + build_dir(&dir, &language); + + // report progress + tx.send(1).unwrap(); + }); + } + assert_eq!(rx.iter().take(n_jobs).fold(0, |a, b| a + b), n_jobs); + build_dir("tree-sitter-typescript/tsx", "tsx"); build_dir("tree-sitter-typescript/typescript", "typescript"); } |