]> git.sesse.net Git - stockfish/commitdiff
Use Thread c'tor to properly init the struct
authorMarco Costalba <mcostalba@gmail.com>
Sat, 13 Feb 2010 10:40:55 +0000 (11:40 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 13 Feb 2010 10:41:34 +0000 (11:41 +0100)
This is what c'tors are for.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp
src/thread.h

index ba9b947845b6f867d297632b9ddd7dce3cc9cc69..fbae76d7720fee3dd5833697b0b70be412428b5c 100644 (file)
@@ -566,9 +566,6 @@ void init_threads() {
   pthread_t pthread[1];
 #endif
 
-  for (i = 0; i < THREAD_MAX; i++)
-      Threads[i].activeSplitPoints = 0;
-
   // Initialize global locks
   lock_init(&MPLock, NULL);
   lock_init(&IOLock, NULL);
@@ -591,12 +588,7 @@ void init_threads() {
 
   // All threads except the main thread should be initialized to idle state
   for (i = 1; i < THREAD_MAX; i++)
-  {
-      Threads[i].stop = false;
-      Threads[i].workIsWaiting = false;
       Threads[i].idle = true;
-      Threads[i].running = false;
-  }
 
   // Launch the helper threads
   for (i = 1; i < THREAD_MAX; i++)
index d8eee1c126de09aaec29c999783a245caa11f329..14924bf2280662be82523e81e94d09a7136d1c16 100644 (file)
@@ -26,6 +26,8 @@
 //// Includes
 ////
 
+#include <cstring>
+
 #include "lock.h"
 #include "movepick.h"
 #include "position.h"
@@ -64,6 +66,9 @@ struct SplitPoint {
 
 
 struct Thread {
+
+  Thread() { memset(this, 0, sizeof(Thread)); }
+
   SplitPoint *splitPoint;
   volatile int activeSplitPoints;
   uint64_t nodes;