mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-08 22:01:47 -04:00
Try to fix the #+lazy entities
This commit is contained in:
1 parent
b06c5ffa70
commit
c6b9f8d998
4 files changed
+568
-7
No files matched your search
+19
-3
@@ -2137,10 +2137,16 @@ gb_internal void check_entity_decl(CheckerContext *ctx, Entity *e, DeclInfo *d,
|
||||
if (e->state == EntityState_Resolved) {
|
||||
return;
|
||||
}
|
||||
GlobalEntityTimingFrame timing_frame = global_entity_timing_begin(e);
|
||||
if (e->flags & EntityFlag_Lazy) {
|
||||
bool is_lazy = (e->flags & EntityFlag_Lazy) != 0;
|
||||
if (is_lazy) {
|
||||
mutex_lock(&ctx->info->lazy_mutex);
|
||||
if (e->state == EntityState_Resolved) {
|
||||
// NOTE: another thread checked it whilst this one waited
|
||||
mutex_unlock(&ctx->info->lazy_mutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GlobalEntityTimingFrame timing_frame = global_entity_timing_begin(e);
|
||||
|
||||
String name = e->token.string;
|
||||
|
||||
@@ -2225,12 +2231,22 @@ gb_internal void check_entity_decl(CheckerContext *ctx, Entity *e, DeclInfo *d,
|
||||
end:;
|
||||
global_entity_timing_end(timing_frame, e);
|
||||
// NOTE(bill): Add it to the list of checked entities
|
||||
if (e->flags & EntityFlag_Lazy) {
|
||||
if (is_lazy) {
|
||||
array_add(&ctx->info->entities, e);
|
||||
mutex_unlock(&ctx->info->lazy_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
// A lazy entity is only ever in progress on the thread holding `lazy_mutex`, so taking it (it is
|
||||
// recursive) waits out another thread and is a no-op on the thread that is checking it
|
||||
gb_internal void wait_for_lazy_entity(CheckerContext *ctx, Entity *e) {
|
||||
if ((e->flags & EntityFlag_Lazy) == 0 || e->state == EntityState_Resolved) {
|
||||
return;
|
||||
}
|
||||
mutex_lock(&ctx->info->lazy_mutex);
|
||||
mutex_unlock(&ctx->info->lazy_mutex);
|
||||
}
|
||||
|
||||
|
||||
gb_internal void add_deps_from_child_to_parent(DeclInfo *decl) {
|
||||
if (decl && decl->parent) {
|
||||
|
||||
Reference in new issue
Block a user