Fix win32 jthread implementation
parent
22dbbf0a6f
commit
35f88ac67c
|
@ -27,7 +27,7 @@ JSemaphore::JSemaphore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
JSemaphore::~JSemaphore() {
|
JSemaphore::~JSemaphore() {
|
||||||
CloseHandle(&m_hSemaphore);
|
CloseHandle(m_hSemaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSemaphore::JSemaphore(int initval) {
|
JSemaphore::JSemaphore(int initval) {
|
||||||
|
|
|
@ -46,14 +46,21 @@ JThread::~JThread()
|
||||||
|
|
||||||
void JThread::Stop() {
|
void JThread::Stop() {
|
||||||
runningmutex.Lock();
|
runningmutex.Lock();
|
||||||
requeststop = false;
|
requeststop = true;
|
||||||
runningmutex.Unlock();
|
runningmutex.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JThread::Wait() {
|
void JThread::Wait() {
|
||||||
int WaitForSingleObject_retval = WaitForSingleObject(threadhandle, INFINITE);
|
runningmutex.Lock();
|
||||||
assert(WaitForSingleObject_retval == 0);
|
if (running)
|
||||||
UNUSED(WaitForSingleObject_retval);
|
{
|
||||||
|
runningmutex.Unlock();
|
||||||
|
WaitForSingleObject(threadhandle, INFINITE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
runningmutex.Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int JThread::Start()
|
int JThread::Start()
|
||||||
|
|
Loading…
Reference in New Issue