aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-04 15:55:10 +0000
committergingerBill <bill@gingerbill.org>2023-01-04 15:55:10 +0000
commit8a99b8af3e875141156d359026b785fcfd284f57 (patch)
treecc64d6f73e6c01b8e2eefc11f830930b9c98002f /src/check_expr.cpp
parent12e42d92d30b3a9cf4d7bb7bb17a2e031285073b (diff)
Narrow mutex usage
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index bce16f304..e9e61486e 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -435,18 +435,17 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
GB_ASSERT(base_entity->identifier.load()->kind == Ast_Ident);
GB_ASSERT(base_entity->kind == Entity_Procedure);
-
mutex_lock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
-
gen_procs = base_entity->Procedure.gen_procs;
if (gen_procs) {
rw_mutex_shared_lock(&gen_procs->mutex); // @local-mutex
+ mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
+
for (Entity *other : gen_procs->procs) {
Type *pt = base_type(other->type);
if (are_types_identical(pt, final_proc_type)) {
rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex
- mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
if (poly_proc_data) {
poly_proc_data->gen_entity = other;
@@ -460,9 +459,9 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
gen_procs = gb_alloc_item(permanent_allocator(), GenProcsData);
gen_procs->procs.allocator = heap_allocator();
base_entity->Procedure.gen_procs = gen_procs;
+ mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
}
- mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
{
// LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice