Use RwMutex for DeclInfo `deps

This commit is contained in:
gingerBill
2023-01-03 15:34:52 +00:00
parent c7a704d345
commit 3dee3205b2
4 changed files with 27 additions and 18 deletions

View File

@@ -4928,21 +4928,23 @@ gb_internal bool check_identifier_exists(Scope *s, Ast *node, bool nested = fals
gb_internal isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) {
if (lhs != nullptr && c->decl != nullptr) {
mutex_lock(&c->info->deps_mutex);
// mutex_lock(&c->info->deps_mutex);
for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
Entity *e = lhs[tuple_index + j];
if (e != nullptr) {
DeclInfo *decl = decl_info_of_entity(e);
if (decl != nullptr) {
rw_mutex_lock(&c->decl->deps_mutex);
for (Entity *dep : decl->deps) {
ptr_set_add(&c->decl->deps, dep);
}
rw_mutex_unlock(&c->decl->deps_mutex);
}
}
}
mutex_unlock(&c->info->deps_mutex);
// mutex_unlock(&c->info->deps_mutex);
}
return tuple_count;
}