diff --git a/Source/Engine/Threading/ThreadRegistry.cpp b/Source/Engine/Threading/ThreadRegistry.cpp index b6844e13f..3dafb4f87 100644 --- a/Source/Engine/Threading/ThreadRegistry.cpp +++ b/Source/Engine/Threading/ThreadRegistry.cpp @@ -47,7 +47,6 @@ void ThreadRegistry::KillEmAll() void ThreadRegistry::Add(Thread* thread) { ASSERT(thread && thread->GetID() != 0); - Locker.Lock(); ASSERT(!Registry.ContainsKey(thread->GetID()) && !Registry.ContainsValue(thread)); Registry.Add(thread->GetID(), thread); @@ -57,9 +56,11 @@ void ThreadRegistry::Add(Thread* thread) void ThreadRegistry::Remove(Thread* thread) { ASSERT(thread && thread->GetID() != 0); - Locker.Lock(); - ASSERT_LOW_LAYER(Registry.ContainsKey(thread->GetID()) && Registry[thread->GetID()] == thread); +#if ENABLE_ASSERTION_LOW_LAYERS + Thread** currentValue = Registry.TryGet(thread->GetID()); + ASSERT_LOW_LAYER(!currentValue || *currentValue == thread); +#endif Registry.Remove(thread->GetID()); Locker.Unlock(); }