Fix a bogus use of mutex
authorMarco Costalba <mcostalba@gmail.com>
Tue, 17 Mar 2015 06:31:45 +0000 (07:31 +0100)
committerJoona Kiiski <joona.kiiski@gmail.com>
Tue, 17 Mar 2015 08:19:29 +0000 (08:19 +0000)
Spinlock must be used instead.

Tested for no regression at 15+0.05 th 4:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 25928 W: 4303 L: 4190 D: 17435

No functional change.

Resolves #297

src/search.cpp

index 08a779565289767d1fa56b63e03671d77ac970fe..b08b687af2408f55d3690645963ae899db907fdd 100644 (file)
@@ -1599,7 +1599,7 @@ void Thread::idle_loop() {
             && !(this_sp && this_sp->slavesMask.none())
             && !searching)
       {
-          if (   !this_sp 
+          if (   !this_sp
               && !Threads.main()->thinking)
           {
               std::unique_lock<Mutex> lk(mutex);
@@ -1613,12 +1613,12 @@ void Thread::idle_loop() {
       // If this thread has been assigned work, launch a search
       while (searching)
       {
-          mutex.lock();
+          spinlock.acquire();
 
           assert(activeSplitPoint);
           SplitPoint* sp = activeSplitPoint;
 
-          mutex.unlock();
+          spinlock.release();
 
           Stack stack[MAX_PLY+4], *ss = stack+2; // To allow referencing (ss-2) and (ss+2)
           Position pos(*sp->pos, this);