]> git.mxchange.org Git - simgear.git/commitdiff
Expose the size() method for locked and blocking thread queues.
authorcurt <curt>
Wed, 15 Sep 2004 15:28:58 +0000 (15:28 +0000)
committercurt <curt>
Wed, 15 Sep 2004 15:28:58 +0000 (15:28 +0000)
simgear/threads/SGQueue.hxx

index 83a1cfebecdf2352117984b8af7bda77eb5280df..532106bf3bdd74e429da907f670d9f8c4f64adda 100644 (file)
@@ -61,6 +61,13 @@ public:
      */
     virtual T pop() = 0;
 
+    /**
+     * Query the size of the queue
+     *
+     * @return size_t size of queue.
+     */
+    virtual size_t size() = 0;
+
 protected:
     /**
      * 
@@ -136,6 +143,17 @@ public:
        this->fifo.pop();
        return item;
     }
+
+    /**
+     * Query the size of the queue
+     *
+     * @return size_t size of queue.
+     */
+    virtual size_t size() {
+       SGGuard<SGLOCK> g(mutex);
+        return this->fifo.size();
+    }
+
 private:
 
     /**
@@ -222,6 +240,16 @@ public:
        return item;
     }
 
+    /**
+     * Query the size of the queue
+     *
+     * @return size_t size of queue.
+     */
+    virtual size_t size() {
+       SGGuard<SGMutex> g(mutex);
+        return this->fifo.size();
+    }
+
 private:
 
     /**