]> git.mxchange.org Git - simgear.git/commitdiff
Terrasync: don't busy wait when no requests are running.
authorJames Turner <zakalawe@mac.com>
Mon, 28 Oct 2013 14:51:36 +0000 (14:51 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 28 Oct 2013 14:51:52 +0000 (14:51 +0000)
simgear/scene/tsync/terrasync.cxx
simgear/threads/SGQueue.hxx

index afe89639df3ecf43e562fac53897f174a720a96b..48c0c64f80e76bf77742b985f185efdf3562ba4e 100644 (file)
@@ -643,6 +643,12 @@ void SGTerraSync::SvnThread::runInternal()
         }
 
         _busy = anySlotBusy;
+        if (!anySlotBusy) {
+            // wait on the blocking deque here, otherwise we spin
+            // the loop very fast, since _http::update with no connections
+            // active returns immediately.
+            waitingTiles.waitOnNotEmpty();
+        }
     } // of thread running loop
 }
 
index c4fab564c36d7f9df8ee865163952e11b6e7297c..7f49b5d97f73775a38ccc8bbe9814875d43525fb 100644 (file)
@@ -386,6 +386,11 @@ public:
         return this->queue.size();
     }
 
+    void waitOnNotEmpty() {
+       SGGuard<SGMutex> g(mutex);
+       while (this->queue.empty())
+           not_empty.wait(mutex);
+    }
 private:
 
     /**