Add top_and_pop fn to TSQueue
This commit is contained in:
parent
ee85ced0e0
commit
0167c4953b
1 changed files with 9 additions and 0 deletions
|
@ -25,6 +25,7 @@ class TSQueue {
|
|||
bool push(const T &data);
|
||||
T top();
|
||||
bool pop();
|
||||
T top_and_pop();
|
||||
void clear();
|
||||
void changeCapacity(unsigned int newCapacity);
|
||||
unsigned int size();
|
||||
|
@ -96,6 +97,14 @@ bool TSQueue<T>::pop() {
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T TSQueue<T>::top_and_pop() {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
T value = rb.top();
|
||||
rb.pop();
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TSQueue<T>::clear() {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
|
Loading…
Reference in a new issue