mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Retire set_timer()
Also assure in Thread::timer_loop() that when timer interval is 0 (timer is disabled) we never call check_time() No functional change.
This commit is contained in:
parent
869c924410
commit
dda7de17e7
3 changed files with 10 additions and 20 deletions
|
@ -239,17 +239,16 @@ void Search::think() {
|
||||||
|
|
||||||
// Set best timer interval to avoid lagging under time pressure. Timer is
|
// Set best timer interval to avoid lagging under time pressure. Timer is
|
||||||
// used to check for remaining available thinking time.
|
// used to check for remaining available thinking time.
|
||||||
if (Limits.use_time_management())
|
Threads.timer_thread()->maxPly = /* Hack: we use maxPly to set timer interval */
|
||||||
Threads.set_timer(std::min(100, std::max(TimeMgr.available_time() / 16,
|
Limits.use_time_management() ? std::min(100, std::max(TimeMgr.available_time() / 16, TimerResolution)) :
|
||||||
TimerResolution)));
|
Limits.nodes ? 2 * TimerResolution
|
||||||
else if (Limits.nodes)
|
: 100;
|
||||||
Threads.set_timer(2 * TimerResolution);
|
|
||||||
else
|
Threads.timer_thread()->notify_one(); // Wake up the recurring timer
|
||||||
Threads.set_timer(100);
|
|
||||||
|
|
||||||
id_loop(RootPos); // Let's start searching !
|
id_loop(RootPos); // Let's start searching !
|
||||||
|
|
||||||
Threads.set_timer(0); // Stop timer
|
Threads.timer_thread()->maxPly = 0; // Stop the timer
|
||||||
|
|
||||||
// Main thread will go to sleep by itself to avoid a race with start_searching()
|
// Main thread will go to sleep by itself to avoid a race with start_searching()
|
||||||
for (size_t i = 0; i < Threads.size(); i++)
|
for (size_t i = 0; i < Threads.size(); i++)
|
||||||
|
|
|
@ -80,7 +80,8 @@ void Thread::timer_loop() {
|
||||||
while (!do_exit)
|
while (!do_exit)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
sleepCondition.wait_for(mutex, maxPly ? maxPly : INT_MAX);
|
while (!maxPly && !do_exit)
|
||||||
|
sleepCondition.wait_for(mutex, maxPly ? maxPly : INT_MAX);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
check_time();
|
check_time();
|
||||||
}
|
}
|
||||||
|
@ -237,16 +238,6 @@ bool ThreadPool::available_slave_exists(Thread* master) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set_timer() is used to set the timer to trigger after msec milliseconds.
|
|
||||||
// If msec is 0 then timer is stopped.
|
|
||||||
|
|
||||||
void ThreadPool::set_timer(int msec) {
|
|
||||||
|
|
||||||
timer->maxPly = msec;
|
|
||||||
timer->notify_one(); // Wake up and restart the timer
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// split() does the actual work of distributing the work at a node between
|
// split() does the actual work of distributing the work at a node between
|
||||||
// several available threads. If it does not succeed in splitting the node
|
// several available threads. If it does not succeed in splitting the node
|
||||||
// (because no idle threads are available, or because we have no unused split
|
// (because no idle threads are available, or because we have no unused split
|
||||||
|
|
|
@ -140,10 +140,10 @@ public:
|
||||||
int min_split_depth() const { return minimumSplitDepth; }
|
int min_split_depth() const { return minimumSplitDepth; }
|
||||||
size_t size() const { return threads.size(); }
|
size_t size() const { return threads.size(); }
|
||||||
Thread* main_thread() { return threads[0]; }
|
Thread* main_thread() { return threads[0]; }
|
||||||
|
Thread* timer_thread() { return timer; }
|
||||||
|
|
||||||
void read_uci_options();
|
void read_uci_options();
|
||||||
bool available_slave_exists(Thread* master) const;
|
bool available_slave_exists(Thread* master) const;
|
||||||
void set_timer(int msec);
|
|
||||||
void wait_for_search_finished();
|
void wait_for_search_finished();
|
||||||
void start_searching(const Position&, const Search::LimitsType&,
|
void start_searching(const Position&, const Search::LimitsType&,
|
||||||
const std::vector<Move>&, Search::StateStackPtr&);
|
const std::vector<Move>&, Search::StateStackPtr&);
|
||||||
|
|
Loading…
Add table
Reference in a new issue