From 4c3b63df255f2ec0c19b828f65ae7ba14c76a95f Mon Sep 17 00:00:00 2001 From: mlokr Date: Fri, 19 Jul 2024 12:39:19 +0200 Subject: [PATCH] c --- hblang/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hblang/src/lib.rs b/hblang/src/lib.rs index 636325d9..553492d2 100644 --- a/hblang/src/lib.rs +++ b/hblang/src/lib.rs @@ -353,7 +353,7 @@ pub fn parse_from_fs(extra_threads: usize, root: &str) -> io::Result> { type Task = (u32, PathBuf, Option); let seen = Mutex::new(HashMap::::default()); - let tasks = TaskQueue::::new(extra_threads); + let tasks = TaskQueue::::new(extra_threads + 1); let ast = Mutex::new(Vec::>::new()); let loader = |path: &str, from: &str| { @@ -430,6 +430,7 @@ pub fn parse_from_fs(extra_threads: usize, root: &str) -> io::Result> { let thread = || { let mut buffer = Vec::new(); while let Some(task @ (indx, ..)) = tasks.pop() { + dbg!(); let res = execute_task(task, &mut buffer); buffer.clear(); @@ -444,7 +445,11 @@ pub fn parse_from_fs(extra_threads: usize, root: &str) -> io::Result> { seen.lock().unwrap().insert(path.clone(), 0); tasks.push((0, path, None)); - std::thread::scope(|s| (0..extra_threads + 1).for_each(|_| _ = s.spawn(thread))); + if extra_threads == 0 { + thread(); + } else { + std::thread::scope(|s| (0..extra_threads + 1).for_each(|_| _ = s.spawn(thread))); + } ast.into_inner().unwrap().into_iter().collect::>>() }