]> git.sesse.net Git - stockfish/commitdiff
Get rid of nativeThread
authorMarco Costalba <mcostalba@gmail.com>
Sat, 21 Mar 2015 10:50:14 +0000 (11:50 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 23 Mar 2015 08:02:52 +0000 (09:02 +0100)
No functional change.

src/endgame.h
src/thread.cpp
src/thread.h
src/uci.cpp

index cd05f0cd1b6273cfa91341d379bc36439d3271d5..f24ac93d44a67e2d3ac286eca0888b205e67e229 100644 (file)
@@ -76,7 +76,7 @@ eg_type = typename std::conditional<(E < SCALING_FUNCTIONS), Value, ScaleFactor>
 template<typename T>
 struct EndgameBase {
 
 template<typename T>
 struct EndgameBase {
 
-  virtual ~EndgameBase() {}
+  virtual ~EndgameBase() = default;
   virtual Color strong_side() const = 0;
   virtual T operator()(const Position&) const = 0;
 };
   virtual Color strong_side() const = 0;
   virtual T operator()(const Position&) const = 0;
 };
index a715d44ee17b2e5844e4be101b246041e9bc9c7d..ef5ae857e30580822b5c05cf2406a413a6eb05f6 100644 (file)
@@ -38,9 +38,9 @@ namespace {
  // when start_routine (and hence virtual idle_loop) is called and when joining.
 
  template<typename T> T* new_thread() {
  // when start_routine (and hence virtual idle_loop) is called and when joining.
 
  template<typename T> T* new_thread() {
-   T* th = new T();
-   th->nativeThread = std::thread(&ThreadBase::idle_loop, th); // Will go to sleep
-   return th;
+   std::thread* th = new T;
+   *th = std::thread(&T::idle_loop, (T*)th); // Will go to sleep
+   return (T*)th;
  }
 
  void delete_thread(ThreadBase* th) {
  }
 
  void delete_thread(ThreadBase* th) {
@@ -50,7 +50,7 @@ namespace {
    th->mutex.unlock();
 
    th->notify_one();
    th->mutex.unlock();
 
    th->notify_one();
-   th->nativeThread.join(); // Wait for thread termination
+   th->join(); // Wait for thread termination
    delete th;
  }
 
    delete th;
  }
 
@@ -61,7 +61,7 @@ namespace {
 
 void ThreadBase::notify_one() {
 
 
 void ThreadBase::notify_one() {
 
-  std::unique_lock<Mutex>(this->mutex);
+  std::unique_lock<Mutex> lk(mutex);
   sleepCondition.notify_one();
 }
 
   sleepCondition.notify_one();
 }
 
index 215b27c688b2823b11112a56e862645cd7c726d0..ee7fb061229e0288ce163eda0ac944bda6118cb6 100644 (file)
@@ -89,14 +89,13 @@ struct SplitPoint {
 /// ThreadBase struct is the base of the hierarchy from where we derive all the
 /// specialized thread classes.
 
 /// ThreadBase struct is the base of the hierarchy from where we derive all the
 /// specialized thread classes.
 
-struct ThreadBase {
+struct ThreadBase : public std::thread {
 
   virtual ~ThreadBase() = default;
   virtual void idle_loop() = 0;
   void notify_one();
   void wait_for(volatile const bool& b);
 
 
   virtual ~ThreadBase() = default;
   virtual void idle_loop() = 0;
   void notify_one();
   void wait_for(volatile const bool& b);
 
-  std::thread nativeThread;
   Mutex mutex;
   Spinlock spinlock;
   ConditionVariable sleepCondition;
   Mutex mutex;
   Spinlock spinlock;
   ConditionVariable sleepCondition;
index 7a0ead60c09de931b0275470501fdbae30c33e9c..2c07807c1b678b2ee0bfb26325439b3853781ffa 100644 (file)
@@ -68,7 +68,7 @@ namespace {
         return;
 
     pos.set(fen, Options["UCI_Chess960"], Threads.main());
         return;
 
     pos.set(fen, Options["UCI_Chess960"], Threads.main());
-    SetupStates = Search::StateStackPtr(new std::stack<StateInfo>());
+    SetupStates = Search::StateStackPtr(new std::stack<StateInfo>);
 
     // Parse move list (if any)
     while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE)
 
     // Parse move list (if any)
     while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE)