From 5eec570768da886625ebce6bad60a7bfb74a4941 Mon Sep 17 00:00:00 2001 From: dean11 Date: Wed, 27 Nov 2013 22:39:49 +0100 Subject: [PATCH] Added an atomic to the reference counter for thread saftey --- Code/Misc/Utilities.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h index 8eaf18f4..f34907de 100644 --- a/Code/Misc/Utilities.h +++ b/Code/Misc/Utilities.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace Utility { @@ -110,12 +111,12 @@ namespace Utility struct ReferenceCount { private: - int count; + std::atomic count; public: ReferenceCount() :count(0) { } - ReferenceCount(const ReferenceCount& o) { count = o.count; } - inline const ReferenceCount& operator=(const ReferenceCount& o) { count = o.count; return *this;} + ReferenceCount(const ReferenceCount& o) { count.store(o.count); } + inline const ReferenceCount& operator=(const ReferenceCount& o) { count.store(o.count); return *this;} inline void Incref() { this->count++; } inline void Incref(int c) { this->count += c; } inline int Decref() { return --this->count;}