summaryrefslogtreecommitdiffstats
path: root/source/cIsThread.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-10 18:37:00 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-10 18:37:00 +0100
commit1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44 (patch)
treed56236f57100b68f5a1f22afbca1d477af4aadf2 /source/cIsThread.cpp
parentWas using "#else if" which is not valid apparently, now using "#elif" (diff)
downloadcuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.tar
cuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.tar.gz
cuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.tar.bz2
cuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.tar.lz
cuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.tar.xz
cuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.tar.zst
cuberite-1a5ebb44aa4ed3aecc84a8d6f0422d504db1ec44.zip
Diffstat (limited to '')
-rw-r--r--source/cIsThread.cpp53
1 files changed, 28 insertions, 25 deletions
diff --git a/source/cIsThread.cpp b/source/cIsThread.cpp
index 61dd23b2a..edde68767 100644
--- a/source/cIsThread.cpp
+++ b/source/cIsThread.cpp
@@ -51,12 +51,12 @@ static void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
// cIsThread:
cIsThread::cIsThread(const AString & iThreadName) :
- mThreadName(iThreadName),
- mShouldTerminate(false),
+ m_ThreadName(iThreadName),
+ m_ShouldTerminate(false),
#ifdef _WIN32
- mHandle(NULL)
+ m_Handle(NULL)
#else // _WIN32
- mHasStarted(false)
+ m_HasStarted(false)
#endif // else _WIN32
{
}
@@ -67,7 +67,7 @@ cIsThread::cIsThread(const AString & iThreadName) :
cIsThread::~cIsThread()
{
- mShouldTerminate = true;
+ m_ShouldTerminate = true;
Wait();
}
@@ -78,34 +78,35 @@ cIsThread::~cIsThread()
bool cIsThread::Start(void)
{
#ifdef _WIN32
- ASSERT(mHandle == NULL); // Has already started one thread?
+ ASSERT(m_Handle == NULL); // Has already started one thread?
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
- mHandle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
- if (mHandle == NULL)
+ m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
+ if (m_Handle == NULL)
{
- LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", mThreadName.c_str(), GetLastError());
+ LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError());
return false;
}
- ResumeThread(mHandle);
+ ResumeThread(m_Handle);
#if defined(_DEBUG) && defined(_MSC_VER)
// Thread naming is available only in MSVC
- if (!mThreadName.empty())
+ if (!m_ThreadName.empty())
{
- SetThreadName(ThreadID, mThreadName.c_str());
+ SetThreadName(ThreadID, m_ThreadName.c_str());
}
#endif // _DEBUG and _MSC_VER
#else // _WIN32
- ASSERT(!mHasStarted);
+ ASSERT(!m_HasStarted);
- if (pthread_create(&mHandle, NULL, thrExecute, this))
+ if (pthread_create(&m_Handle, NULL, thrExecute, this))
{
- LOGERROR("ERROR: Could not create thread \"%s\", !", mThreadName.c_str());
+ LOGERROR("ERROR: Could not create thread \"%s\", !", m_ThreadName.c_str());
return false;
}
+ m_HasStarted = true;
#endif // else _WIN32
return true;
@@ -119,28 +120,30 @@ bool cIsThread::Wait(void)
{
#ifdef _WIN32
- if (mHandle == NULL)
+ if (m_Handle == NULL)
{
return true;
}
// Cannot log, logger may already be stopped:
- // LOG("Waiting for thread \"%s\" to terminate.", mThreadName.c_str());
- int res = WaitForSingleObject(mHandle, INFINITE);
- mHandle = NULL;
+ // LOG("Waiting for thread \"%s\" to terminate.", m_ThreadName.c_str());
+ int res = WaitForSingleObject(m_Handle, INFINITE);
+ m_Handle = NULL;
// Cannot log, logger may already be stopped:
- // LOG("Thread \"%s\" %s terminated, GLE = %d", mThreadName.c_str(), (res == WAIT_OBJECT_0) ? "" : "not", GetLastError());
+ // LOG("Thread \"%s\" %s terminated, GLE = %d", m_ThreadName.c_str(), (res == WAIT_OBJECT_0) ? "" : "not", GetLastError());
return (res == WAIT_OBJECT_0);
#else // _WIN32
- if (!mHasStarted)
+ if (!m_HasStarted)
{
return true;
}
- LOG("Waiting for thread \"%s\" to terminate.", mThreadName.c_str());
- int res = pthread_join(mHandle, NULL);
- mHasStarted = false;
- LOG("Thread \"%s\" %s terminated, errno = %d", mThreadName.c_str(), (res == 0) ? "" : "not", errno);
+ // Cannot log, logger may already be stopped:
+ // LOG("Waiting for thread \"%s\" to terminate.", m_ThreadName.c_str());
+ int res = pthread_join(m_Handle, NULL);
+ m_HasStarted = false;
+ // Cannot log, logger may already be stopped:
+ // LOG("Thread \"%s\" %s terminated, errno = %d", m_ThreadName.c_str(), (res == 0) ? "" : "not", errno);
return (res == 0);
#endif // else _WIN32