summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-12-07 15:46:27 +0100
committerMattes D <github@xoft.cz>2014-12-07 15:46:27 +0100
commit3c3cb198f33fd55b9cb20188cc42034b21660d21 (patch)
tree282d86969d4a2cbad5a64a27d1e17a5bad8dbed6 /src/OSSupport
parentMerge pull request #1555 from mc-server/c++11 (diff)
downloadcuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar
cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.gz
cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.bz2
cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.lz
cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.xz
cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.zst
cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/IsThread.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index 9c62c89bf..94bed1f56 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -85,7 +85,7 @@ bool cIsThread::Start(void)
}
catch (std::system_error & a_Exception)
{
- LOGERROR("cIsThread::Wait (std::thread) error %i: could not construct thread %s; %s", a_Exception.code().value(), m_ThreadName.c_str(), a_Exception.what());
+ LOGERROR("cIsThread::Start error %i: could not construct thread %s; %s", a_Exception.code().value(), m_ThreadName.c_str(), a_Exception.code().message().c_str());
return false;
}
}
@@ -96,6 +96,12 @@ bool cIsThread::Start(void)
void cIsThread::Stop(void)
{
+ if (!m_Thread.joinable())
+ {
+ // The thread hasn't been started or has already been joined
+ return;
+ }
+
m_ShouldTerminate = true;
Wait();
}
@@ -106,10 +112,7 @@ void cIsThread::Stop(void)
bool cIsThread::Wait(void)
{
- #ifdef LOGD // ProtoProxy doesn't have LOGD
- LOGD("Waiting for thread %s to finish", m_ThreadName.c_str());
- #endif // LOGD
-
+ LOGD("Waiting for thread %s to finish", m_ThreadName.c_str());
if (m_Thread.joinable())
{
try
@@ -119,15 +122,12 @@ bool cIsThread::Wait(void)
}
catch (std::system_error & a_Exception)
{
- LOGERROR("cIsThread::Wait (std::thread) error %i: could not join thread %s; %s", a_Exception.code().value(), m_ThreadName.c_str(), a_Exception.what());
+ LOGERROR("cIsThread::Wait error %i: could not join thread %s; %s", a_Exception.code().value(), m_ThreadName.c_str(), a_Exception.code().message().c_str());
return false;
}
}
- #ifdef LOGD // ProtoProxy doesn't have LOGD
- LOGD("Thread %s finished", m_ThreadName.c_str());
- #endif
-
+ LOGD("Thread %s finished", m_ThreadName.c_str());
return true;
}