From 35a3a1b9f4fd52b37106271964157fc3b7a9ee84 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 3 Jan 2015 22:20:30 +0100 Subject: [PATCH] cByteBuffer: Improved SingleThreadAccessChecker performance. But it's still poor and unusable for regular testing. --- src/ByteBuffer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index b441d61ca..e1e5867a9 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -131,7 +131,7 @@ public: { ASSERT( (*a_ThreadID == std::this_thread::get_id()) || // Either the object is used by current thread... - (*a_ThreadID == std::thread::id()) // ... or by no thread at all + (*a_ThreadID == m_EmptyThreadID) // ... or by no thread at all ); // Mark as being used by this thread: @@ -147,8 +147,13 @@ public: protected: /** Points to the storage used for ID of the thread using the object. */ std::thread::id * m_ThreadID; + + /** The value of an unassigned thread ID, used to speed up checking. */ + static std::thread::id m_EmptyThreadID; }; + std::thread::id cSingleThreadAccessChecker::m_EmptyThreadID; + #define CHECK_THREAD cSingleThreadAccessChecker Checker(&m_ThreadID); #else