diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-27 23:00:51 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-27 23:00:51 +0100 |
| commit | 4bc3796f9b9e8ea00ff0da89f6e983345fb2fd7e (patch) | |
| tree | 4c715e376db71a6079cd6681b3ba4695ad2f88d8 | |
| parent | 5e12f5a746dbc21d1ee97b8367af23a9dcb5d980 (diff) | |
Short circuit `check_with_workers` logic on `worker_count == 0`
| -rw-r--r-- | src/checker.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index fb4ef5477..649f84c93 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -4078,7 +4078,18 @@ void check_with_workers(Checker *c, gbThreadProc *proc, isize total_count) { worker_count = 0; } - gb_semaphore_post(&c->info.collect_semaphore, cast(i32)worker_count); + gb_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; + gbThread dummy_main_thread = {}; + dummy_main_thread.user_data = §ion_all; + proc(&dummy_main_thread); + return; + } isize file_load_count = (total_count+thread_count-1)/thread_count; isize remaining_count = total_count; @@ -4713,7 +4724,7 @@ void check_procedure_bodies(Checker *c) { GB_ASSERT(total_queued == original_queue_count); - gb_semaphore_post(&c->procs_to_check_semaphore, cast(i32)worker_count); + gb_semaphore_post(&c->procs_to_check_semaphore, cast(i32)thread_count); gbThread *threads = gb_alloc_array(permanent_allocator(), gbThread, worker_count); for (isize i = 0; i < worker_count; i++) { |