summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-12-05 16:59:11 +0100
committerMattes D <github@xoft.cz>2014-12-05 16:59:11 +0100
commite2a04f580a0813206f527a61244cb3382248fd12 (patch)
tree39f0a5026d619e89ce353cf8addf18e4a696b067 /src/OSSupport
parentCheckBasicStyle: Added a check for parentheses around comparisons. (diff)
downloadcuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.gz
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.bz2
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.lz
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.xz
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.zst
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.zip
Diffstat (limited to 'src/OSSupport')
-rw-r--r--src/OSSupport/Thread.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp
index faaccce96..6188d5088 100644
--- a/src/OSSupport/Thread.cpp
+++ b/src/OSSupport/Thread.cpp
@@ -83,12 +83,16 @@ cThread::~cThread()
void cThread::Start( bool a_bWaitOnDelete /* = true */)
{
if (a_bWaitOnDelete)
+ {
m_StopEvent = new cEvent();
+ }
#ifndef _WIN32
pthread_t SndThread;
if (pthread_create( &SndThread, NULL, MyThread, this))
+ {
LOGERROR("ERROR: Could not create thread!");
+ }
#else
DWORD ThreadID = 0;
HANDLE hThread = CreateThread(NULL // security
@@ -132,6 +136,11 @@ void *cThread::MyThread( void *a_Param)
ThreadFunction( ThreadParam);
- if (StopEvent) StopEvent->Set();
+ // If the thread was marked as wait-on-delete, signal the event being waited on:
+ if (StopEvent != nullptr)
+ {
+ StopEvent->Set();
+ }
+
return 0;
}