Fix win32 jthread implementation
authorsapier <Sapier at GMX dot net>
Fri, 6 Dec 2013 16:49:10 +0000 (17:49 +0100)
committersapier <Sapier at GMX dot net>
Fri, 6 Dec 2013 16:49:10 +0000 (17:49 +0100)
src/jthread/win32/jsemaphore.cpp [changed mode: 0644->0755]
src/jthread/win32/jthread.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8eca6d2..3a1f271
@@ -27,7 +27,7 @@ JSemaphore::JSemaphore() {
 }
 
 JSemaphore::~JSemaphore() {
-       CloseHandle(&m_hSemaphore);
+       CloseHandle(m_hSemaphore);
 }
 
 JSemaphore::JSemaphore(int initval) {
old mode 100644 (file)
new mode 100755 (executable)
index 0781982..6a745c5
@@ -46,14 +46,21 @@ JThread::~JThread()
 
 void JThread::Stop() {
        runningmutex.Lock();
-       requeststop = false;
+       requeststop = true;
        runningmutex.Unlock();
 }
 
 void JThread::Wait() {
-       int WaitForSingleObject_retval = WaitForSingleObject(threadhandle, INFINITE);
-       assert(WaitForSingleObject_retval == 0);
-       UNUSED(WaitForSingleObject_retval);
+       runningmutex.Lock();
+       if (running)
+       {
+               runningmutex.Unlock();
+               WaitForSingleObject(threadhandle, INFINITE);
+       }
+       else
+       {
+               runningmutex.Unlock();
+       }
 }
 
 int JThread::Start()