Narrow global gen_procs_mutex further

This commit is contained in:
gingerBill
2023-01-02 23:50:48 +00:00
parent fd62ee14cd
commit e10fe91eba
3 changed files with 5 additions and 7 deletions

View File

@@ -439,7 +439,6 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
// @@GPM //////////////////////////
mutex_lock(&info->gen_procs_mutex);
///////////////////////////////////
auto *found = map_get(&info->gen_procs, base_entity->identifier.load());
if (found) {
gen_procs = *found;
@@ -462,6 +461,9 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
gen_procs->procs.allocator = heap_allocator();
map_set(&info->gen_procs, base_entity->identifier.load(), gen_procs);
}
// @@GPM ////////////////////////////
mutex_unlock(&info->gen_procs_mutex);
/////////////////////////////////////
{
// LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice
@@ -475,11 +477,6 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
// LEAK TODO(bill): Cloning this AST may be leaky
Ast *cloned_proc_type_node = clone_ast(pt->node);
success = check_procedure_type(&nctx, final_proc_type, cloned_proc_type_node, &operands);
// @@GPM ////////////////////////////
mutex_unlock(&info->gen_procs_mutex);
/////////////////////////////////////
if (!success) {
return false;
}

View File

@@ -51,6 +51,7 @@ gb_internal bool check_rtti_type_disallowed(Ast *expr, Type *type, char const *f
gb_internal void scope_reset(Scope *scope) {
if (scope == nullptr) return;
MUTEX_GUARD(&scope->mutex);
scope->head_child.store(nullptr, std::memory_order_relaxed);
string_map_clear(&scope->elements);
ptr_set_clear(&scope->imported);

View File

@@ -167,7 +167,7 @@ gb_internal THREAD_PROC(thread_pool_thread_proc) {
idx = (idx + 1) % cast(usize)pool->threads.count;
Thread *thread = &pool->threads.data[idx];
WorkerTask task, another_task;
WorkerTask task;
if (!thread_pool_queue_pop(thread, &task)) {
continue;
}