-#include "thread_win32.h"
-
-
-/// Thread struct keeps together all the thread related stuff. 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 std::thread {
-
- Thread();
- virtual ~Thread();
- virtual void search();
- void idle_loop();
- void join();
- void notify_one();
- void wait(std::atomic_bool& b);
-
- std::atomic_bool exit, searching, resetCalls;
- Mutex mutex;
- ConditionVariable sleepCondition;
-
- Pawns::Table pawnsTable;
- Material::Table materialTable;
- Endgames endgames;
- size_t idx, PVIdx;
- int maxPly, callsCnt;
-
- Position rootPos;
- Search::RootMoveVector rootMoves;
- Depth rootDepth;
- HistoryStats history;
- MovesStats counterMoves;
- Depth completedDepth;
+#include "thread_win32_osx.h"
+#include "types.h"
+
+namespace Stockfish {
+
+// Thread class keeps together all the thread-related stuff.
+class Thread {
+
+ std::mutex mutex;
+ std::condition_variable cv;
+ size_t idx;
+ bool exit = false, searching = true; // Set before starting std::thread
+ NativeThread stdThread;
+
+ public:
+ explicit Thread(size_t);
+ virtual ~Thread();
+ virtual void search();
+ void clear();
+ void idle_loop();
+ void start_searching();
+ void wait_for_search_finished();
+ size_t id() const { return idx; }
+
+ size_t pvIdx, pvLast;
+ std::atomic<uint64_t> nodes, tbHits, bestMoveChanges;
+ int selDepth, nmpMinPly;
+ Value bestValue, optimism[COLOR_NB];
+
+ Position rootPos;
+ StateInfo rootState;
+ Search::RootMoves rootMoves;
+ Depth rootDepth, completedDepth;
+ Value rootDelta;
+ Value rootSimpleEval;
+ CounterMoveHistory counterMoves;
+ ButterflyHistory mainHistory;
+ CapturePieceToHistory captureHistory;
+ ContinuationHistory continuationHistory[2][2];
+ PawnHistory pawnHistory;