From: Marco Costalba Date: Thu, 22 Mar 2012 21:39:10 +0000 (+0100) Subject: Merge two loops in ThreadsManager::init() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=c47a74ec62c8c4fdacf6d16eef068b62634122f1;ds=sidebyside Merge two loops in ThreadsManager::init() In analogy with ThreadsManager::exit() No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/misc.h b/src/misc.h index f37fd5ef..84ea9cd5 100644 --- a/src/misc.h +++ b/src/misc.h @@ -30,6 +30,7 @@ extern const std::string engine_info(bool to_uci = false); extern int cpu_count(); extern void timed_wait(WaitCondition&, Lock&, int); extern void prefetch(char* addr); +extern void start_logger(bool b); extern void dbg_hit_on(bool b); extern void dbg_hit_on_c(bool c, bool b); @@ -60,6 +61,4 @@ private: sys_time_t t; }; -extern void start_logger(bool b); - #endif // !defined(MISC_H_INCLUDED) diff --git a/src/thread.cpp b/src/thread.cpp index 358ced5d..31c5961d 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -221,15 +221,6 @@ void ThreadsManager::init() { cond_init(sleepCond); lock_init(splitLock); - for (int i = 0; i <= MAX_THREADS; i++) - { - lock_init(threads[i].sleepLock); - cond_init(threads[i].sleepCond); - - for (int j = 0; j < MAX_SPLITPOINTS_PER_THREAD; j++) - lock_init(threads[i].splitPoints[j].lock); - } - // Allocate main thread tables to call evaluate() also when not searching threads[0].pawnTable.init(); threads[0].materialTable.init(); @@ -241,6 +232,12 @@ void ThreadsManager::init() { threads[i].do_sleep = (i != 0); // Avoid a race with start_thinking() threads[i].threadID = i; + lock_init(threads[i].sleepLock); + cond_init(threads[i].sleepCond); + + for (int j = 0; j < MAX_SPLITPOINTS_PER_THREAD; j++) + lock_init(threads[i].splitPoints[j].lock); + if (!thread_create(threads[i].handle, start_routine, threads[i])) { std::cerr << "Failed to create thread number " << i << std::endl;