From a90fe7211c226ab6dd7580ec2323758a98214bf7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 19 Aug 2021 17:44:26 +0100 Subject: Make `global_entity_id` atomic --- src/entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/entity.cpp') 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 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; } -- cgit v1.2.3