summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/IsThread.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2015-01-25 00:34:19 +0100
committerHowaner <franzi.moos@googlemail.com>2015-01-25 00:34:19 +0100
commit1eedccc56a1a80b42adbea8dbbe968d42c7fe712 (patch)
treea5fe3fb72a3c3918b2c4ba413c686f718f5d403c /src/OSSupport/IsThread.cpp
parentC++11 and function rename. (diff)
parentGamosocm support (diff)
downloadcuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.gz
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.bz2
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.lz
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.xz
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.zst
cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/IsThread.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index 94bed1f56..55e96b622 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -68,11 +68,22 @@ cIsThread::~cIsThread()
+void cIsThread::DoExecute(void)
+{
+ m_evtStart.Wait();
+ Execute();
+}
+
+
+
+
+
bool cIsThread::Start(void)
{
try
{
- m_Thread = std::thread(&cIsThread::Execute, this);
+ // Initialize the thread:
+ m_Thread = std::thread(&cIsThread::DoExecute, this);
#if defined (_MSC_VER) && defined(_DEBUG)
if (!m_ThreadName.empty())
@@ -81,9 +92,12 @@ bool cIsThread::Start(void)
}
#endif
+ // Notify the thread that initialization is complete and it can run its code safely:
+ m_evtStart.Set();
+
return true;
}
- catch (std::system_error & a_Exception)
+ catch (const std::system_error & a_Exception)
{
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;