| 176 | } |
| 177 | |
| 178 | static 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* |
no test coverage detected