diff --git a/simgear/scene/tsync/terrasync.cxx b/simgear/scene/tsync/terrasync.cxx index afe89639..48c0c64f 100644 --- a/simgear/scene/tsync/terrasync.cxx +++ b/simgear/scene/tsync/terrasync.cxx @@ -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 } diff --git a/simgear/threads/SGQueue.hxx b/simgear/threads/SGQueue.hxx index c4fab564..7f49b5d9 100644 --- a/simgear/threads/SGQueue.hxx +++ b/simgear/threads/SGQueue.hxx @@ -386,6 +386,11 @@ public: return this->queue.size(); } + void waitOnNotEmpty() { + SGGuard g(mutex); + while (this->queue.empty()) + not_empty.wait(mutex); + } private: /**