summaryrefslogtreecommitdiffstats
path: root/source/cIsThread.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
commit4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch)
treefebea3ecd89c0d4aa83924e430bf11366d754733 /source/cIsThread.cpp
parentNew makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff)
downloadcuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip
Diffstat (limited to 'source/cIsThread.cpp')
-rw-r--r--source/cIsThread.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/cIsThread.cpp b/source/cIsThread.cpp
index 4aa25b534..3f4442f7f 100644
--- a/source/cIsThread.cpp
+++ b/source/cIsThread.cpp
@@ -67,6 +67,7 @@ cIsThread::cIsThread(const AString & iThreadName) :
cIsThread::~cIsThread()
{
+ mShouldTerminate = true;
Wait();
}
@@ -81,7 +82,7 @@ bool cIsThread::Start(void)
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
- HANDLE mHandle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
+ mHandle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
if (mHandle == NULL)
{
LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", mThreadName.c_str(), GetLastError());
@@ -122,10 +123,12 @@ bool cIsThread::Wait(void)
{
return true;
}
- LOG("Waiting for thread \"%s\" to terminate.", mThreadName.c_str());
+ // 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("Thread \"%s\" %s terminated, GLE = %d", mThreadName.c_str(), (res == WAIT_OBJECT_0) ? "" : "not", GetLastError());
+ // Cannot log, logger may already be stopped:
+ // LOG("Thread \"%s\" %s terminated, GLE = %d", mThreadName.c_str(), (res == WAIT_OBJECT_0) ? "" : "not", GetLastError());
return (res == WAIT_OBJECT_0);
#else // _WIN32