fix for 45337 and some other little things
This commit is contained in:
@ -54,6 +54,9 @@ void ThreadWorker::RunThread(IThreadHandle *pHandle)
|
||||
/**
|
||||
* Check number of items in the queue
|
||||
*/
|
||||
m_StateLock->Lock();
|
||||
this_state = m_state;
|
||||
m_StateLock->Unlock();
|
||||
if (this_state != Worker_Stopped)
|
||||
{
|
||||
m_QueueLock->Lock();
|
||||
@ -65,6 +68,11 @@ void ThreadWorker::RunThread(IThreadHandle *pHandle)
|
||||
*/
|
||||
m_Waiting = true;
|
||||
m_QueueLock->Unlock();
|
||||
/* first check if we should end again */
|
||||
if (this_state == Worker_Stopped)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_AddSignal->Wait();
|
||||
m_Waiting = false;
|
||||
} else {
|
||||
@ -80,7 +88,9 @@ void ThreadWorker::RunThread(IThreadHandle *pHandle)
|
||||
{
|
||||
//wait until the lock is cleared.
|
||||
if (this_state == Worker_Paused)
|
||||
{
|
||||
m_PauseSignal->Wait();
|
||||
}
|
||||
if (this_state == Worker_Stopped)
|
||||
{
|
||||
//if we're supposed to flush cleanrly,
|
||||
@ -187,9 +197,12 @@ bool ThreadWorker::Stop(bool flush_cancel)
|
||||
{
|
||||
Unpause();
|
||||
} else {
|
||||
m_AddSignal->Signal();
|
||||
Pause();
|
||||
Unpause();
|
||||
m_QueueLock->Lock();
|
||||
if (m_Waiting)
|
||||
{
|
||||
m_AddSignal->Signal();
|
||||
}
|
||||
m_QueueLock->Unlock();
|
||||
}
|
||||
|
||||
me->WaitForThread();
|
||||
|
@ -97,7 +97,7 @@ IThreadHandle *WinThreader::MakeThread(IThread *pThread, const ThreadParams *par
|
||||
|
||||
IEventSignal *WinThreader::MakeEventSignal()
|
||||
{
|
||||
HANDLE event = CreateEventA(NULL, TRUE, TRUE, NULL);
|
||||
HANDLE event = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
|
||||
if (!event)
|
||||
return NULL;
|
||||
@ -275,7 +275,6 @@ WinThreader::WinEvent::~WinEvent()
|
||||
void WinThreader::WinEvent::Wait()
|
||||
{
|
||||
WaitForSingleObject(m_event, INFINITE);
|
||||
ResetEvent(m_event);
|
||||
}
|
||||
|
||||
void WinThreader::WinEvent::Signal()
|
||||
|
Reference in New Issue
Block a user