+ Value beta;
+ int nodeType;
+ bool cutNode;
+
+ // Const pointers to shared data
+ MovePicker* movePicker;
+ SplitPoint* parentSplitPoint;
+
+ // Shared variable data
+ Spinlock spinlock;
+ std::bitset<MAX_THREADS> slavesMask;
+ volatile bool allSlavesSearching;
+ volatile uint64_t nodes;
+ volatile Value alpha;
+ volatile Value bestValue;
+ volatile Move bestMove;
+ volatile int moveCount;
+ volatile bool cutoff;
+};
+
+
+/// ThreadBase struct is the base of the hierarchy from where we derive all the
+/// specialized thread classes.
+
+struct ThreadBase {
+
+ virtual ~ThreadBase() = default;
+ virtual void idle_loop() = 0;
+ void notify_one();
+ void wait_for(volatile const bool& b);
+
+ std::thread nativeThread;
+ std::mutex mutex;
+ std::condition_variable sleepCondition;
+ volatile bool exit = false;
+};
+
+
+/// 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 can_join(const SplitPoint* sp) const;
+
+ void split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
+ Depth depth, int moveCount, MovePicker* movePicker, int nodeType, bool cutNode);
+
+ SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
+ Pawns::Table pawnsTable;
+ Material::Table materialTable;
+ Endgames endgames;
+ Position* activePosition;
+ size_t idx;
+ int maxPly;
+ SplitPoint* volatile activeSplitPoint;
+ volatile size_t splitPointsSize;
+ volatile bool searching;