]> git.sesse.net Git - stockfish/blobdiff - src/thread.cpp
Replace Position::copy()
[stockfish] / src / thread.cpp
index 5136a233db14b819fa7d73d397384f18ba2e176e..cb3f8223aacf26a93199c7c2ed6cef1b8a02916c 100644 (file)
@@ -34,15 +34,11 @@ namespace { extern "C" {
  // start_routine() is the C function which is called when a new thread
  // is launched. It is a wrapper to member function pointed by start_fn.
 
  // start_routine() is the C function which is called when a new thread
  // is launched. It is a wrapper to member function pointed by start_fn.
 
- long start_routine(Thread* th) {
-
-   Threads.set_this_thread(th); // Save pointer into thread local storage
-   (th->*(th->start_fn))();
-   return 0;
- }
+ long start_routine(Thread* th) { (th->*(th->start_fn))(); return 0; }
 
 } }
 
 
 } }
 
+
 // Thread c'tor starts a newly-created thread of execution that will call
 // the idle loop function pointed by start_fn going immediately to sleep.
 
 // Thread c'tor starts a newly-created thread of execution that will call
 // the idle loop function pointed by start_fn going immediately to sleep.
 
@@ -205,7 +201,6 @@ bool Thread::is_available_to(Thread* master) const {
 
 void ThreadsManager::init() {
 
 
 void ThreadsManager::init() {
 
-  tls_init(tlsKey);
   cond_init(sleepCond);
   lock_init(splitLock);
   timer = new Thread(&Thread::timer_loop);
   cond_init(sleepCond);
   lock_init(splitLock);
   timer = new Thread(&Thread::timer_loop);
@@ -224,7 +219,6 @@ ThreadsManager::~ThreadsManager() {
   delete timer;
   lock_destroy(splitLock);
   cond_destroy(sleepCond);
   delete timer;
   lock_destroy(splitLock);
   cond_destroy(sleepCond);
-  tls_destroy(tlsKey);
 }
 
 
 }
 
 
@@ -313,7 +307,7 @@ Value ThreadsManager::split(Position& pos, Stack* ss, Value alpha, Value beta,
   assert(beta <= VALUE_INFINITE);
   assert(depth > DEPTH_ZERO);
 
   assert(beta <= VALUE_INFINITE);
   assert(depth > DEPTH_ZERO);
 
-  Thread* master = Threads.this_thread();
+  Thread* master = pos.this_thread();
 
   if (master->splitPointsCnt >= MAX_SPLITPOINTS_PER_THREAD)
       return bestValue;
 
   if (master->splitPointsCnt >= MAX_SPLITPOINTS_PER_THREAD)
       return bestValue;