mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 17:46:26 +08:00
Use only one ConditionVariable to sync UI
To sync UI with main thread it is enough a single condition variable because here we have a single producer / single consumer design pattern. Two condition variables are strictly needed just for many producers / many consumers case. Note that this is possible because now we don't send to sleep idle threads anymore while searching, so that now only UI can wake up the main thread and we can use the same ConditionVariable for both threads. The natural consequence is to retire wait_for_think_finished() and move all the logic under MainThread class, yielding the rename of teh function to join() No functional change.
This commit is contained in:
@@ -137,6 +137,7 @@ struct Thread : public ThreadBase {
|
||||
|
||||
struct MainThread : public Thread {
|
||||
virtual void idle_loop();
|
||||
void join();
|
||||
volatile bool thinking = true; // Avoid a race with start_thinking()
|
||||
};
|
||||
|
||||
@@ -162,11 +163,9 @@ struct ThreadPool : public std::vector<Thread*> {
|
||||
MainThread* main() { return static_cast<MainThread*>(at(0)); }
|
||||
void read_uci_options();
|
||||
Thread* available_slave(const SplitPoint* sp) const;
|
||||
void wait_for_think_finished();
|
||||
void start_thinking(const Position&, const Search::LimitsType&, Search::StateStackPtr&);
|
||||
|
||||
Depth minimumSplitDepth;
|
||||
ConditionVariable sleepCondition;
|
||||
TimerThread* timer;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user