]> git.mxchange.org Git - simgear.git/blobdiff - simgear/threads/SGQueue.hxx
Tweak HTTP code to always sleep.
[simgear.git] / simgear / threads / SGQueue.hxx
index 37122c5ae150be619b48a62e85cba2ad1a6393ea..7f49b5d97f73775a38ccc8bbe9814875d43525fb 100644 (file)
@@ -127,8 +127,8 @@ public:
      */
     virtual T pop() {
        SGGuard<SGMutex> g(mutex);
-       //if (fifo.empty()) throw NoSuchElementException();
-       assert( ! this->fifo.empty() );
+           if (this->fifo.empty()) return T(); // assumes T is default constructable
+        
 //     if (fifo.empty())
 //     {
 //         mutex.unlock();
@@ -386,6 +386,11 @@ public:
         return this->queue.size();
     }
 
+    void waitOnNotEmpty() {
+       SGGuard<SGMutex> g(mutex);
+       while (this->queue.empty())
+           not_empty.wait(mutex);
+    }
 private:
 
     /**