-class ThreadsManager {
- /* As long as the single ThreadsManager object is defined as a global we don't
- need to explicitly initialize to zero its data members because variables with
- static storage duration are automatically set to zero before enter main()
- */
-public:
- void init(); // No c'tor becuase Threads is static and we need engine initialized
- ~ThreadsManager();
-
- Thread& operator[](int id) { return *threads[id]; }
- bool use_sleeping_threads() const { return useSleepingThreads; }
- int min_split_depth() const { return minimumSplitDepth; }
- int size() const { return (int)threads.size(); }
- Thread* main_thread() const { return threads[0]; }
- Thread* this_thread() const { return (Thread*)tls_get(tlsKey); }
- void set_this_thread(Thread* th) const { tls_set(tlsKey, th); }
-
- void wake_up() const;
- void sleep() const;
+struct MainThread : public Thread {
+ virtual void search();
+ void check_time();
+
+ bool easyMovePlayed, failedLow;
+ double bestMoveChanges;
+ Value previousScore;
+ int callsCnt = 0;
+};
+
+
+/// ThreadPool struct handles all the threads-related stuff like init, starting,
+/// parking and, most importantly, launching a thread. All the access to threads
+/// data is done through this class.
+
+struct ThreadPool : public std::vector<Thread*> {
+
+ void init(); // No constructor and destructor, threads rely on globals that should
+ void exit(); // be initialized and valid during the whole thread lifetime.
+
+ MainThread* main() { return static_cast<MainThread*>(at(0)); }
+ void start_thinking(Position&, StateListPtr&, const Search::LimitsType&);