X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.h;h=606f96262dd72ead3f3672a45c1148f840efcb97;hp=ba9197ce4aabe43ab316b02f802f8efcdfc1a89a;hb=8d16111ffde1689d48d47ec379ba91613213183c;hpb=3c07603dac03f0da20194097cf4eb1a396fea60d diff --git a/src/thread.h b/src/thread.h index ba9197ce..606f9626 100644 --- a/src/thread.h +++ b/src/thread.h @@ -34,10 +34,9 @@ struct Thread; -const int MAX_THREADS = 128; -const int MAX_SPLITPOINTS_PER_THREAD = 8; - -struct Thread; +const size_t MAX_THREADS = 128; +const size_t MAX_SPLITPOINTS_PER_THREAD = 8; +const size_t MAX_SLAVES_PER_SPLITPOINT = 4; /// SplitPoint struct stores information shared by the threads searching in /// parallel below the same split point. It is populated at splitting time. @@ -47,7 +46,7 @@ struct SplitPoint { // Const data after split point has been setup const Position* pos; Search::Stack* ss; - Thread* masterThread; + Thread* master; Depth depth; Value beta; int nodeType; @@ -75,8 +74,7 @@ struct SplitPoint { struct ThreadBase { - ThreadBase() : exit(false) {} - virtual ~ThreadBase() {} + virtual ~ThreadBase() = default; virtual void idle_loop() = 0; void notify_one(); void wait_for(volatile const bool& b); @@ -84,7 +82,7 @@ struct ThreadBase { std::thread nativeThread; std::mutex mutex; std::condition_variable sleepCondition; - volatile bool exit; + volatile bool exit = false; }; @@ -111,7 +109,7 @@ struct Thread : public ThreadBase { size_t idx; int maxPly; SplitPoint* volatile activeSplitPoint; - volatile int splitPointsSize; + volatile size_t splitPointsSize; volatile bool searching; }; @@ -120,19 +118,17 @@ struct Thread : public ThreadBase { /// special threads: the main one and the recurring timer. struct MainThread : public Thread { - MainThread() : thinking(true) {} // Avoid a race with start_thinking() virtual void idle_loop(); - volatile bool thinking; + volatile bool thinking = true; // Avoid a race with start_thinking() }; struct TimerThread : public ThreadBase { static const int Resolution = 5; // Millisec between two check_time() calls - TimerThread() : run(false) {} virtual void idle_loop(); - bool run; + bool run = false; };