summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-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;
}