diff --git a/cpp_impl/src/TSQueue.hpp b/cpp_impl/src/TSQueue.hpp index 947f76c..1985eee 100644 --- a/cpp_impl/src/TSQueue.hpp +++ b/cpp_impl/src/TSQueue.hpp @@ -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::pop() { return true; } +template +T TSQueue::top_and_pop() { + std::lock_guard lock(mutex); + T value = rb.top(); + rb.pop(); + return value; +} + template void TSQueue::clear() { std::lock_guard lock(mutex);