]> git.sesse.net Git - stockfish/blobdiff - src/thread.h
Refactor Thread class
[stockfish] / src / thread.h
index e71db835734d7bd2bc146b0cf71332e0d9b6ca61..a88bb6d311c6e14474ee7d0cc411025866586555 100644 (file)
@@ -66,6 +66,9 @@ struct SplitPoint {
 
 struct Thread {
 
+  Thread(int id);
+  ~Thread();
+
   void wake_up();
   bool cutoff_occurred() const;
   bool is_available_to(int master) const;
@@ -100,7 +103,7 @@ class ThreadsManager {
      static storage duration are automatically set to zero before enter main()
   */
 public:
-  Thread& operator[](int threadID) { return threads[threadID]; }
+  Thread& operator[](int threadID) { return *threads[threadID]; }
   void init();
   void exit();
 
@@ -108,7 +111,8 @@ public:
   int min_split_depth() const { return minimumSplitDepth; }
   int size() const { return activeThreads; }
 
-  void set_size(int cnt);
+  void wake_up();
+  void sleep();
   void read_uci_options();
   bool available_slave_exists(int master) const;
   void set_timer(int msec);
@@ -122,7 +126,8 @@ public:
 private:
   friend struct Thread;
 
-  Thread threads[MAX_THREADS + 1]; // Last one is used as a timer
+  Thread* timer;
+  Thread* threads[MAX_THREADS];
   Lock splitLock;
   WaitCondition sleepCond;
   Depth minimumSplitDepth;