mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Im just trying things at this point, Bill should just squash this PR at merge time ;)
This commit is contained in:
+11
-5
@@ -4690,6 +4690,7 @@ struct ParserWorkerThreadData {
|
|||||||
|
|
||||||
gbMutex lock; //NOTE(thebirk): All variables below are locked by this mutex
|
gbMutex lock; //NOTE(thebirk): All variables below are locked by this mutex
|
||||||
bool error_available;
|
bool error_available;
|
||||||
|
bool is_working;
|
||||||
bool should_exit;
|
bool should_exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4716,8 +4717,9 @@ GB_THREAD_PROC(parse_worker_file_proc) {
|
|||||||
data->err = process_imported_file(p, file_to_process);
|
data->err = process_imported_file(p, file_to_process);
|
||||||
|
|
||||||
data->error_available = true;
|
data->error_available = true;
|
||||||
gb_semaphore_release(&p->worker_finished_semaphore);
|
data->is_working = false;
|
||||||
gb_mutex_unlock(&data->lock);
|
gb_mutex_unlock(&data->lock);
|
||||||
|
gb_semaphore_release(&p->worker_finished_semaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
//GB_PANIC("A worker thread should not be able to reach the end!!!");
|
//GB_PANIC("A worker thread should not be able to reach the end!!!");
|
||||||
@@ -4818,7 +4820,7 @@ ParseFileError parse_packages(Parser *p, String init_filename) {
|
|||||||
gbThread *t = &worker_threads[i];
|
gbThread *t = &worker_threads[i];
|
||||||
ParserWorkerThreadData *data = &worker_threads_data[i];
|
ParserWorkerThreadData *data = &worker_threads_data[i];
|
||||||
|
|
||||||
if (gb_mutex_try_lock(&data->lock)) {
|
if (!data->is_working && gb_mutex_try_lock(&data->lock)) {
|
||||||
if (data->error_available) {
|
if (data->error_available) {
|
||||||
auto curr_err = data->err;
|
auto curr_err = data->err;
|
||||||
if (curr_err != ParseFile_None) {
|
if (curr_err != ParseFile_None) {
|
||||||
@@ -4834,6 +4836,7 @@ ParseFileError parse_packages(Parser *p, String init_filename) {
|
|||||||
num_alive += 1;
|
num_alive += 1;
|
||||||
|
|
||||||
gb_semaphore_release(&data->resume_work);
|
gb_semaphore_release(&data->resume_work);
|
||||||
|
data->is_working = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_mutex_unlock(&data->lock);
|
gb_mutex_unlock(&data->lock);
|
||||||
@@ -4844,20 +4847,23 @@ ParseFileError parse_packages(Parser *p, String init_filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
while (num_alive > 0) {
|
while (num_alive > 0) {
|
||||||
isize prev_files_to_process = p->files_to_process.count;
|
isize prev_files_to_process = p->files_to_process.count;
|
||||||
gb_semaphore_wait(&p->worker_finished_semaphore);
|
gb_semaphore_wait(&p->worker_finished_semaphore);
|
||||||
num_alive -= 1;
|
num_alive -= 1;
|
||||||
|
|
||||||
if (prev_files_to_process < p->files_to_process.count) {
|
if ((prev_files_to_process < p->files_to_process.count)) {
|
||||||
if (num_alive > 0) {
|
if (num_alive > 0) {
|
||||||
//NOTE(thebirk): Recreate semaphore to avoid overflowing the counter. Only needs to happen when there are more threads alive
|
//NOTE(thebirk): Recreate semaphore to avoid overflowing the counter. Only needs to happen when there are more threads alive
|
||||||
gb_semaphore_destroy(&p->worker_finished_semaphore);
|
//gb_semaphore_destroy(&p->worker_finished_semaphore);
|
||||||
gb_semaphore_init(&p->worker_finished_semaphore);
|
//gb_semaphore_init(&p->worker_finished_semaphore);
|
||||||
}
|
}
|
||||||
|
printf("Early out!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
if ((num_alive == 0) && (curr_import_index >= p->files_to_process.count)) {
|
if ((num_alive == 0) && (curr_import_index >= p->files_to_process.count)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user