aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/compiler.c b/src/compiler.c
index dc703f8..fbdeb94 100644
--- a/src/compiler.c
+++ b/src/compiler.c
@@ -335,22 +335,30 @@ static CHECK_RESULT int amal_compiler_dispatch_generic(amal_compiler *self, Thre
return amal_compiler_load_file_join_threads(self);
}
+/*
+amal_compiler_load_file is called by the user for the first file to compile
+but also called by the parser when it sees @import
+*/
int amal_compiler_load_file(amal_compiler *self, BufferView filepath) {
int result;
ParserThreadData *parser_thread_data;
ThreadWorkData thread_work_data;
+ bool main_job;
+
result = AMAL_COMPILER_ERR;
thread_work_data.type = THREAD_WORK_PARSE;
thread_work_data.value.filepath = filepath;
+ main_job = bool_false;
- return_if_error(amal_compiler_select_thread_for_work(self, thread_work_data, &parser_thread_data));
-
- /*
- amal_compiler_load_file is called by the user for the first file to compile
- but also called by the parser when it sees @import
- */
+ /* The first time we get here, this will run single-threaded so this part doesn't need mutex */
if(!self->started) {
self->started = bool_true;
+ main_job = bool_true;
+ }
+
+ return_if_error(amal_compiler_select_thread_for_work(self, thread_work_data, &parser_thread_data));
+
+ if(main_job) {
/*amal_log_info("Parsing %.*s using %d thread(s)", (int)filepath.size, filepath.data, self->usable_thread_count);*/
/*return_if_error(amal_compiler_load_first_this_thread(self, filepath, &self->main_thread_allocator));*/
return_if_error(amal_compiler_load_file_join_threads(self));