+
+/// Thread struct keeps 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 : public ThreadBase {
+
+ Thread();
+ virtual void idle_loop();
+ bool cutoff_occurred() const;
+ bool available_to(const Thread* master) const;
+
+ template <bool Fake>
+ void split(Position& pos, const Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
+ Depth depth, Move threatMove, int moveCount, MovePicker* movePicker, int nodeType, bool cutNode);
+
+ SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
+ Material::Table materialTable;
+ Endgames endgames;
+ Pawns::Table pawnsTable;
+ Position* activePosition;
+ size_t idx;
+ int maxPly;
+ SplitPoint* volatile activeSplitPoint;
+ volatile int splitPointsSize;
+ volatile bool searching;
+};
+
+
+/// MainThread and TimerThread are derived classes used to characterize the two
+/// 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;
+};
+
+struct TimerThread : public ThreadBase {
+ TimerThread() : run(false) {}
+ virtual void idle_loop();
+ bool run;
+ static const int Resolution = 5; // msec between two check_time() calls