-
-// init() is called during startup. Initializes locks and condition variables
-// and launches all threads sending them immediately to sleep.
-
-void ThreadsManager::init() {
-
- cond_init(sleepCond);
- lock_init(splitLock);
- timer = new Thread(&Thread::timer_loop);
- threads.push_back(new Thread(&Thread::main_loop));
- read_uci_options();
-}
-
-
-// exit() is called to cleanly terminate the threads before the program finishes
-
-void ThreadsManager::exit() {
-
- for (int i = 0; i < size(); i++)
- delete threads[i];
-
- delete timer;
- lock_destroy(splitLock);
- cond_destroy(sleepCond);
-}
-
-
-// available_slave_exists() tries to find an idle thread which is available as
-// a slave for the thread with threadID 'master'.
-
-bool ThreadsManager::available_slave_exists(int master) const {
-
- assert(master >= 0 && master < size());
-
- for (int i = 0; i < size(); i++)
- if (threads[i]->is_available_to(master))
- return true;
-
- return false;