+
+/// ThreadPool struct handles all the threads related stuff like init, starting,
+/// parking and, the most important, launching a slave thread at a split point.
+/// All the access to shared thread data is done through this class.
+
+struct ThreadPool : public std::vector<Thread*> {
+
+ void init(); // No c'tor and d'tor, threads rely on globals that should
+ void exit(); // be initialized and valid during the whole thread lifetime.
+
+ MainThread* main_thread() { return static_cast<MainThread*>((*this)[0]); }
+ void read_uci_options();
+ Thread* available_slave(Thread* master) const;
+ void wait_for_think_finished();
+ void start_thinking(const Position&, const Search::LimitsType&,
+ const std::vector<Move>&, Search::StateStackPtr&);
+
+ bool sleepWhileIdle;
+ Depth minimumSplitDepth;
+ size_t maxThreadsPerSplitPoint;
+ Mutex mutex;
+ ConditionVariable sleepCondition;
+ TimerThread* timer;
+};
+
+extern ThreadPool Threads;
+
+#endif // #ifndef THREAD_H_INCLUDED