fix EventImpl_Win32::Signal race condition (looks like Broadcast now)
This commit is contained in:
@@ -390,16 +390,19 @@ bool EventImpl_Win32::Wait( RageTimer *pTimeout )
|
|||||||
void EventImpl_Win32::Signal()
|
void EventImpl_Win32::Signal()
|
||||||
{
|
{
|
||||||
EnterCriticalSection( &m_iNumWaitingLock );
|
EnterCriticalSection( &m_iNumWaitingLock );
|
||||||
bool bHaveWaiters = (m_iNumWaiting > 0);
|
|
||||||
|
if( m_iNumWaiting == 0 )
|
||||||
|
{
|
||||||
|
LeaveCriticalSection( &m_iNumWaitingLock );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseSemaphore( m_WakeupSema, 1, 0 );
|
||||||
|
|
||||||
LeaveCriticalSection( &m_iNumWaitingLock );
|
LeaveCriticalSection( &m_iNumWaitingLock );
|
||||||
|
|
||||||
if( bHaveWaiters )
|
/* The waiter will touch m_WaitersDone. */
|
||||||
{
|
WaitForSingleObject( m_WaitersDone, INFINITE );
|
||||||
ReleaseSemaphore( m_WakeupSema, 1, 0 );
|
|
||||||
|
|
||||||
/* The waiter will touch m_WaitersDone. */
|
|
||||||
WaitForSingleObject( m_WaitersDone, INFINITE );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventImpl_Win32::Broadcast()
|
void EventImpl_Win32::Broadcast()
|
||||||
|
|||||||
Reference in New Issue
Block a user