summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-03 22:20:30 +0100
committerMattes D <github@xoft.cz>2015-01-03 22:24:12 +0100
commit35a3a1b9f4fd52b37106271964157fc3b7a9ee84 (patch)
treebeb22bff6062a6d301c5d48c96368fe9371a1c22 /src
parentMerge pull request #1691 from tonibm19/patch-3 (diff)
downloadcuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.tar
cuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.tar.gz
cuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.tar.bz2
cuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.tar.lz
cuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.tar.xz
cuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.tar.zst
cuberite-35a3a1b9f4fd52b37106271964157fc3b7a9ee84.zip
Diffstat (limited to '')
-rw-r--r--src/ByteBuffer.cpp7
1 files changed, 6 insertions, 1 deletions
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