summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/IsThread.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-06-17 19:03:56 +0200
committerHowaner <franzi.moos@googlemail.com>2014-06-17 19:03:56 +0200
commitc60ba8a52d6f84316eae041a24e395a4c37ae181 (patch)
treeedb983f4b20312115bc1033a2bd5a89c615ed30e /src/OSSupport/IsThread.cpp
parentCheck block type from cBlockEntity (diff)
parentMerge pull request #1099 from Howaner/Blocks (diff)
downloadcuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar
cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.gz
cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.bz2
cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.lz
cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.xz
cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.zst
cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.zip
Diffstat (limited to 'src/OSSupport/IsThread.cpp')
-rw-r--r--src/OSSupport/IsThread.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index 04fc818e4..67f336c97 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -60,6 +60,9 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName)
cIsThread::cIsThread(const AString & iThreadName) :
m_ShouldTerminate(false),
m_ThreadName(iThreadName),
+ #ifdef _WIN32
+ m_ThreadID(0),
+ #endif
m_Handle(NULL_HANDLE)
{
}
@@ -83,8 +86,8 @@ bool cIsThread::Start(void)
ASSERT(m_Handle == NULL_HANDLE); // Has already started one thread?
#ifdef _WIN32
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
- DWORD ThreadID = 0;
- m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
+ m_ThreadID = 0;
+ m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &m_ThreadID);
if (m_Handle == NULL)
{
LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError());
@@ -96,7 +99,7 @@ bool cIsThread::Start(void)
// Thread naming is available only in MSVC
if (!m_ThreadName.empty())
{
- SetThreadName(ThreadID, m_ThreadName.c_str());
+ SetThreadName(m_ThreadID, m_ThreadName.c_str());
}
#endif // _DEBUG and _MSC_VER
@@ -177,3 +180,15 @@ unsigned long cIsThread::GetCurrentID(void)
+bool cIsThread::IsCurrentThread(void) const
+{
+ #ifdef _WIN32
+ return (GetCurrentThreadId() == m_ThreadID);
+ #else
+ return (m_Handle == pthread_self());
+ #endif
+}
+
+
+
+