From: Marco Costalba Date: Mon, 14 Jan 2013 18:32:30 +0000 (+0100) Subject: Fix a bug in timer loop X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=78a953177397f3eb85cfee4398975e8519895e6b;hp=d1143794a01cd0540cf47e3415815cd60cde9422 Fix a bug in timer loop Silly logic bug introduced in dda7de17e74d7e8 Timer thread, when msec = 0, instead of going to sleep, calls check_time() in an endless loop. Spotted and reported by snino64 due to abnormally high CPU usage. No functional change. --- diff --git a/src/thread.cpp b/src/thread.cpp index bc0b3fcc..5f3b4d31 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -76,9 +76,10 @@ void TimerThread::idle_loop() { while (!do_exit) { mutex.lock(); - while (!msec && !do_exit) - sleepCondition.wait_for(mutex, msec ? msec : INT_MAX); + do sleepCondition.wait_for(mutex, msec ? msec : INT_MAX); + while (!msec && !do_exit); // Don't allow wakeups when msec = 0 mutex.unlock(); + check_time(); } }