From: sapier Date: Fri, 6 Dec 2013 16:49:10 +0000 (+0100) Subject: Fix win32 jthread implementation X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=35f88ac67c872077206f01d05589dc208ee5851f;p=zefram%2Fminetest%2Fminetest_engine.git Fix win32 jthread implementation --- diff --git a/src/jthread/win32/jsemaphore.cpp b/src/jthread/win32/jsemaphore.cpp old mode 100644 new mode 100755 index 8eca6d24..3a1f2715 --- a/src/jthread/win32/jsemaphore.cpp +++ b/src/jthread/win32/jsemaphore.cpp @@ -27,7 +27,7 @@ JSemaphore::JSemaphore() { } JSemaphore::~JSemaphore() { - CloseHandle(&m_hSemaphore); + CloseHandle(m_hSemaphore); } JSemaphore::JSemaphore(int initval) { diff --git a/src/jthread/win32/jthread.cpp b/src/jthread/win32/jthread.cpp old mode 100644 new mode 100755 index 0781982e..6a745c59 --- a/src/jthread/win32/jthread.cpp +++ b/src/jthread/win32/jthread.cpp @@ -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()