Browse Source

Don't use the thread pool if worker count is 0

gingerBill 4 years ago
parent
commit
6d49df1d87
1 changed files with 24 additions and 1 deletions
  1. 24 1
      src/checker.cpp

+ 24 - 1
src/checker.cpp

@@ -4146,8 +4146,16 @@ void check_with_workers(Checker *c, WorkerTaskProc *proc, isize total_count) {
 	if (!build_context.threaded_checker) {
 	if (!build_context.threaded_checker) {
 		worker_count = 0;
 		worker_count = 0;
 	}
 	}
-
+	
 	semaphore_post(&c->info.collect_semaphore, cast(i32)thread_count);
 	semaphore_post(&c->info.collect_semaphore, cast(i32)thread_count);
+	if (worker_count == 0) {
+		ThreadProcCheckerSection section_all = {};
+		section_all.checker = c;
+		section_all.offset = 0;
+		section_all.count = total_count;
+		proc(&section_all);
+		return;
+	}
 
 
 	isize file_load_count = (total_count+thread_count-1)/thread_count;
 	isize file_load_count = (total_count+thread_count-1)/thread_count;
 	isize remaining_count = total_count;
 	isize remaining_count = total_count;
@@ -4754,6 +4762,21 @@ void check_procedure_bodies(Checker *c) {
 	if (!build_context.threaded_checker) {
 	if (!build_context.threaded_checker) {
 		worker_count = 0;
 		worker_count = 0;
 	}
 	}
+	if (worker_count == 0) {
+		auto *this_queue = &c->procs_to_check_queue;
+		
+		UntypedExprInfoMap untyped = {};
+		map_init(&untyped, heap_allocator());
+		
+		for (ProcInfo *pi = nullptr; mpmc_dequeue(this_queue, &pi); /**/) {
+			consume_proc_info_queue(c, pi, this_queue, &untyped);
+		}
+		
+		map_destroy(&untyped);
+
+		debugf("Total Procedure Bodies Checked: %td\n", total_bodies_checked.load(std::memory_order_relaxed));
+		return;
+	}
 
 
 	global_procedure_body_in_worker_queue = true;
 	global_procedure_body_in_worker_queue = true;