MCPcopy Create free account
hub / github.com/ZDoom/Raze / pthread_cond_wait

Function pthread_cond_wait

libraries/webp/src/utils/thread_utils.c:178–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178static int pthread_cond_wait(pthread_cond_t* const condition,
179 pthread_mutex_t* const mutex) {
180 int ok;
181#ifdef USE_WINDOWS_CONDITION_VARIABLE
182 ok = SleepConditionVariableCS(condition, mutex, INFINITE);
183#else
184 // note that there is a consumer available so the signal isn't dropped in
185 // pthread_cond_signal
186 if (!ReleaseSemaphore(condition->waiting_sem_, 1, NULL)) return 1;
187 // now unlock the mutex so pthread_cond_signal may be issued
188 pthread_mutex_unlock(mutex);
189 ok = (WaitForSingleObject(condition->signal_event_, INFINITE) ==
190 WAIT_OBJECT_0);
191 ok &= ReleaseSemaphore(condition->received_sem_, 1, NULL);
192 pthread_mutex_lock(mutex);
193#endif
194 return !ok;
195}
196
197#else // !_WIN32
198# define THREADFN void*

Callers 4

ThreadLoopFunction · 0.85
ChangeStateFunction · 0.85
Event_WaitFunction · 0.85
Semaphore_WaitFunction · 0.85

Calls 2

pthread_mutex_unlockFunction · 0.85
pthread_mutex_lockFunction · 0.85

Tested by

no test coverage detected