1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Move Thread::idle_loop() where it belongs

No functional change.
This commit is contained in:
Marco Costalba 2015-10-07 09:31:53 +02:00
parent caba255a1c
commit 32d2c4e12b
2 changed files with 21 additions and 21 deletions

View file

@ -1572,27 +1572,6 @@ bool RootMove::extract_ponder_from_tt(Position& pos)
}
/// Thread::idle_loop() is where the thread is parked when it has no work to do
void Thread::idle_loop() {
while (!exit)
{
// If this thread has been assigned work, launch a search
if (searching)
this->search();
// If search is finished then sleep
if (!Threads.main()->thinking)
{
std::unique_lock<Mutex> lk(mutex);
while (!exit && !Threads.main()->thinking)
sleepCondition.wait(lk);
}
}
}
/// check_time() is called by the timer thread when the timer triggers. It is
/// used to print debug info and, more importantly, to detect when we are out of
/// available time and thus stop the search.

View file

@ -106,6 +106,27 @@ void TimerThread::idle_loop() {
}
// Thread::idle_loop() is where the thread is parked when it has no work to do
void Thread::idle_loop() {
while (!exit)
{
// If this thread has been assigned work, launch a search
if (searching)
this->search();
// If search is finished then sleep
if (!Threads.main()->thinking)
{
std::unique_lock<Mutex> lk(mutex);
while (!exit && !Threads.main()->thinking)
sleepCondition.wait(lk);
}
}
}
// MainThread::idle_loop() is where the main thread is parked waiting to be started
// when there is a new search. The main thread will launch all the slave threads.