mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 08:36:33 +08:00
Revert cond_signal() fix
It seems it yields to missing wake-up events with the result of SF loosing on time as reported by many people. So revert the patch and use a more robust approach: assume there can be spurious wake ups events and make the code to work also in those cases. While debugging I found that WaitForSingleObject() had wrong parameter 0 instead of INFINITE yielding to a crash while exiting under Windows, strangely unnoticed til now. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -202,7 +202,7 @@ void ThreadsManager::exit() {
|
||||
|
||||
// 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);
|
||||
@@ -452,7 +452,8 @@ void ThreadsManager::start_thinking(const Position& pos, const LimitsType& limit
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user