Browse Source

Repositioned the sleep in the worker thread for improved performance in starting work.

Lasse Öörni 14 years ago
parent
commit
f50422a04b
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Engine/Core/WorkQueue.cpp

+ 3 - 3
Engine/Core/WorkQueue.cpp

@@ -180,6 +180,9 @@ void WorkQueue::ProcessItems(unsigned threadIndex)
         if (shutDown_)
             return;
         
+        if (queue_.Empty())
+            Time::Sleep(0);
+        
         queueMutex_.Acquire();
         if (!queue_.Empty())
         {
@@ -201,9 +204,6 @@ void WorkQueue::ProcessItems(unsigned threadIndex)
                 wasActive = false;
             }
             queueMutex_.Release();
-            // When transitioning from working to waiting, give up the time slice so that it is easier
-            // for the main thread to re-lock the mutex
-            Time::Sleep(0);
         }
     }
 }