-/// Thread struct is used to keep together all the thread related stuff like locks,
-/// state and especially split points. We also use per-thread pawn and material hash
-/// tables so that once we get a pointer to an entry its life time is unlimited and
-/// we don't have to care about someone changing the entry under our feet.
-
-struct Thread {
-
- enum ThreadState
- {
- AVAILABLE, // Thread is waiting for work
- WORKISWAITING, // Master has ordered us to start searching
- SEARCHING // Thread is performing work
- };
-
- void wake_up();
- bool cutoff_occurred() const;
- bool is_available_to(int master) const;
- void idle_loop(SplitPoint* sp);
-
- SplitPoint splitPoints[MAX_ACTIVE_SPLIT_POINTS];
- MaterialInfoTable materialTable;
- PawnInfoTable pawnTable;
- int threadID;
- int maxPly;
- Lock sleepLock;
- WaitCondition sleepCond;
- volatile ThreadState state;
- SplitPoint* volatile splitPoint;
- volatile int activeSplitPoints;
- volatile bool do_sleep;
- volatile bool do_terminate;
-
-#if defined(_MSC_VER)
- HANDLE handle;
-#else
- pthread_t handle;
-#endif
+/// MainThread is a derived class specific for main thread
+
+struct MainThread : public Thread {
+
+ using Thread::Thread;
+
+ void search() override;
+ void check_time();
+
+ double bestMoveChanges, previousTimeReduction;
+ Value previousScore;
+ int callsCnt;