+ return !spCnt || (splitPoints[spCnt - 1].slavesMask & (1ULL << master->idx));
+}
+
+
+// init() is called at startup. Initializes lock and condition variable and
+// launches requested threads sending them immediately to sleep. We cannot use
+// a c'tor becuase Threads is a static object and we need a fully initialized
+// engine at this point due to allocation of endgames in Thread c'tor.
+
+void ThreadPool::init() {
+
+ cond_init(sleepCond);
+ lock_init(splitLock);
+ timer = new Thread(&Thread::timer_loop);
+ threads.push_back(new Thread(&Thread::main_loop));
+ read_uci_options();
+}
+
+
+// d'tor cleanly terminates the threads when the program exits.
+
+ThreadPool::~ThreadPool() {
+
+ for (int i = 0; i < size(); i++)
+ delete threads[i];
+
+ delete timer;
+ lock_destroy(splitLock);
+ cond_destroy(sleepCond);