Expose the size() method for locked and blocking thread queues.
This commit is contained in:
@@ -61,6 +61,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual T pop() = 0;
|
virtual T pop() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the size of the queue
|
||||||
|
*
|
||||||
|
* @return size_t size of queue.
|
||||||
|
*/
|
||||||
|
virtual size_t size() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -136,6 +143,17 @@ public:
|
|||||||
this->fifo.pop();
|
this->fifo.pop();
|
||||||
return item;
|
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:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,6 +240,16 @@ public:
|
|||||||
return item;
|
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:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user