io/m_event_win32-ng.c
/* Pass in locked critical section, returns locked critical section */
Pass in locked critical section, returns locked critical section
Pass in locked critical section returns locked critical section
static void M_event_win32_sync_wait(M_event_win32_sync_t *sync, CRITICAL_SECTION *lock)
{
	LeaveCriticalSection(lock);
	WaitForSingleObject(sync->sem, INFINITE);
	M_atomic_inc_u32(&sync->waiters);
	ReleaseSemaphore(sync->sem, 1, NULL);
	WaitForSingleObject(sync->broadcast, INFINITE);
	if (M_atomic_dec_u32(&sync->waiters) == 1) {
		ResetEvent(sync->broadcast);
		ReleaseSemaphore(sync->sem, 1, NULL);
	}
	EnterCriticalSection(lock);
}
static void M_event_win32_sync_wait ( M_event_win32_sync_t * sync , CRITICAL_SECTION * lock ) { LeaveCriticalSection ( lock ) ; WaitForSingleObject ( sync -> sem , INFINITE ) ; M_atomic_inc_u32 ( & sync -> waiters ) ; ReleaseSemaphore ( sync -> sem , 1 , NULL ) ; WaitForSingleObject ( sync -> broadcast , INFINITE ) ; if ( M_atomic_dec_u32 ( & sync -> waiters ) == 1 ) { ResetEvent ( sync -> broadcast ) ; ReleaseSemaphore ( sync -> sem , 1 , NULL ) ; } EnterCriticalSection ( lock ) ; }
Pass in locked critical section, returns locked critical section
Pass in locked critical section returns locked critical section
/* Lock is held before we enter, unlock it, we don't need it */ /* Make sure other threads don't clobber us, and also makes sure we don't add
	 * ourselves until a prior wake event is complete */ /* Stop the wakeup sequence and allow more waiters */