]> git.sesse.net Git - stockfish/blobdiff - src/thread.cpp
Merge two loops in ThreadsManager::init()
[stockfish] / src / thread.cpp
index 358ced5dec3bf26eb823af4bd82ad8041801ca89..31c5961d2fc104f7af2d12afec86f7ee73f56ea2 100644 (file)
@@ -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;