From: Marco Costalba Date: Sat, 13 Feb 2010 10:40:55 +0000 (+0100) Subject: Use Thread c'tor to properly init the struct X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=093dd8fe88d278db6cd5c956a771a45a295e1de3 Use Thread c'tor to properly init the struct This is what c'tors are for. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/search.cpp b/src/search.cpp index ba9b9478..fbae76d7 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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++) diff --git a/src/thread.h b/src/thread.h index d8eee1c1..14924bf2 100644 --- a/src/thread.h +++ b/src/thread.h @@ -26,6 +26,8 @@ //// Includes //// +#include + #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;