# define cond_init(x) { *x = CreateEvent(0, FALSE, FALSE, 0); }
# define cond_destroy(x) CloseHandle(*x)
# define cond_signal(x) SetEvent(*x)
-# define cond_wait(x,y) { ResetEvent(*x); lock_release(y); WaitForSingleObject(*x, INFINITE); lock_grab(y); }
-# define cond_timedwait(x,y,z) { ResetEvent(*x); lock_release(y); WaitForSingleObject(*x,z); lock_grab(y); }
+# define cond_wait(x,y) { lock_release(y); WaitForSingleObject(*x, INFINITE); lock_grab(y); }
+# define cond_timedwait(x,y,z) { lock_release(y); WaitForSingleObject(*x,z); lock_grab(y); }
#endif
// Wait for thread termination
#if defined(_MSC_VER)
- WaitForSingleObject(threads[i].handle, 0);
+ WaitForSingleObject(threads[i].handle, INFINITE);
CloseHandle(threads[i].handle);
#else
pthread_join(threads[i].handle, NULL);
cond_signal(&main.sleepCond); // Wake up main thread and start searching
if (!asyncMode)
- cond_wait(&sleepCond, &main.sleepLock);
+ while (!main.do_sleep)
+ cond_wait(&sleepCond, &main.sleepLock);
lock_release(&main.sleepLock);
}