]> git.sesse.net Git - stockfish/commitdiff
Reformat all_slaves_finished()
authorMarco Costalba <mcostalba@gmail.com>
Sun, 6 Nov 2011 12:37:18 +0000 (13:37 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 6 Nov 2011 12:45:47 +0000 (13:45 +0100)
Rename and move under ThreadsManager class.

No functional change.

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

index 8257b5bb9f33d308ef668539e75ccb4f89567f12..40e548dc301da8e231d377c858b133615a87189b 100644 (file)
@@ -2071,20 +2071,8 @@ split_point_start: // At split points actual search starts from here
 
     do pos.undo_move(pv[--ply]); while (ply);
   }
 
     do pos.undo_move(pv[--ply]); while (ply);
   }
-} // namespace
-
-
-// Little helper used by idle_loop() to check that all the slave threads of a
-// split point have finished searching.
-
-static bool all_slaves_finished(SplitPoint* sp) {
 
 
-  for (int i = 0; i < Threads.size(); i++)
-      if (sp->is_slave[i])
-          return false;
-
-  return true;
-}
+} // namespace
 
 
 // Thread::idle_loop() is where the thread is parked when it has no work to do.
 
 
 // Thread::idle_loop() is where the thread is parked when it has no work to do.
@@ -2114,7 +2102,7 @@ void Thread::idle_loop(SplitPoint* sp) {
           lock_grab(&sleepLock);
 
           // If we are master and all slaves have finished don't go to sleep
           lock_grab(&sleepLock);
 
           // If we are master and all slaves have finished don't go to sleep
-          if (sp && all_slaves_finished(sp))
+          if (sp && Threads.split_point_finished(sp))
           {
               lock_release(&sleepLock);
               break;
           {
               lock_release(&sleepLock);
               break;
@@ -2166,7 +2154,7 @@ void Thread::idle_loop(SplitPoint* sp) {
 
       // If this thread is the master of a split point and all slaves have
       // finished their work at this split point, return from the idle loop.
 
       // If this thread is the master of a split point and all slaves have
       // finished their work at this split point, return from the idle loop.
-      if (sp && all_slaves_finished(sp))
+      if (sp && Threads.split_point_finished(sp))
       {
           // Because sp->is_slave[] is reset under lock protection,
           // be sure sp->lock has been released before to return.
       {
           // Because sp->is_slave[] is reset under lock protection,
           // be sure sp->lock has been released before to return.
index df76dcca7a2e1fe990c4859bd23219afcc8188f8..ca9fe14d8fa48dfee160df9e454fbfadb2013f53 100644 (file)
@@ -239,6 +239,19 @@ bool ThreadsManager::available_slave_exists(int master) const {
 }
 
 
 }
 
 
+// split_point_finished() checks if all the slave threads of a given split
+// point have finished searching.
+
+bool ThreadsManager::split_point_finished(SplitPoint* sp) const {
+
+  for (int i = 0; i < activeThreads; i++)
+      if (sp->is_slave[i])
+          return false;
+
+  return true;
+}
+
+
 // split() does the actual work of distributing the work at a node between
 // several available threads. If it does not succeed in splitting the
 // node (because no idle threads are available, or because we have no unused
 // split() does the actual work of distributing the work at a node between
 // several available threads. If it does not succeed in splitting the
 // node (because no idle threads are available, or because we have no unused
index 46ce03aa318c07ea1d66a29a6439b886d4e496c0..e6d400942c3a3cf9102496f783d6a06473fe4b46 100644 (file)
@@ -114,6 +114,7 @@ public:
   void set_size(int cnt);
   void read_uci_options();
   bool available_slave_exists(int master) const;
   void set_size(int cnt);
   void read_uci_options();
   bool available_slave_exists(int master) const;
+  bool split_point_finished(SplitPoint* sp) const;
 
   void getline(std::string& cmd);
   void start_listener();
 
   void getline(std::string& cmd);
   void start_listener();