X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=b8686f4c48e5f69d0bed038ab9cab3bcfdf8cc18;hp=54b42d461ccad7db189d5f920084439bce20583f;hb=699f700162f410519e5510c667aebc9940d4e91e;hpb=797c960d2004eacbbd19c656f483f070130bb358 diff --git a/src/thread.cpp b/src/thread.cpp index 54b42d46..b8686f4c 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -34,10 +34,14 @@ 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. - long start_routine(Thread* th) { (th->*(th->start_fn))(); return 0; } + long start_routine(Thread* th) { -} } + Threads.set_this_thread(th); // Save pointer into thread local storage + (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. @@ -201,6 +205,7 @@ bool Thread::is_available_to(const Thread& master) const { void ThreadsManager::init() { + tls_init(tlsKey); cond_init(sleepCond); lock_init(splitLock); timer = new Thread(&Thread::timer_loop); @@ -219,6 +224,7 @@ ThreadsManager::~ThreadsManager() { delete timer; lock_destroy(splitLock); cond_destroy(sleepCond); + tls_destroy(tlsKey); }