diff options
| author | gingerBill <bill@gingerbill.org> | 2021-08-19 17:44:26 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-08-19 17:44:26 +0100 |
| commit | a90fe7211c226ab6dd7580ec2323758a98214bf7 (patch) | |
| tree | 24d55b65da532a40a89bbf75bcd91ab6878afcd8 /src/entity.cpp | |
| parent | ac6cc5191aed17bdedbe4162d250359616c34286 (diff) | |
Make `global_entity_id` atomic
Diffstat (limited to 'src/entity.cpp')
| -rw-r--r-- | src/entity.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/entity.cpp b/src/entity.cpp index 9f3b8f84d..a916f3099 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -250,7 +250,7 @@ bool entity_has_deferred_procedure(Entity *e) { } -gb_global u64 global_entity_id = 0; +gb_global std::atomic<u64> global_entity_id = 0; Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { gbAllocator a = permanent_allocator(); @@ -260,7 +260,7 @@ Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { entity->scope = scope; entity->token = token; entity->type = type; - entity->id = ++global_entity_id; + entity->id = 1 + global_entity_id.fetch_add(1); return entity; } |