1 #ifndef THREAD_SAFE_QUEUE_HPP
2 #define THREAD_SAFE_QUEUE_HPP
22 template <
typename TType>
26 std::deque<TType> _queue;
32 std::lock_guard<std::mutex> lock(_mutex);
33 _queue.push_back(newElement);
38 std::lock_guard<std::mutex> lock(_mutex);
39 _queue.push_front(newElement);
44 std::lock_guard<std::mutex> lock(_mutex);
47 throw std::runtime_error(
"Trying to pop from an empty queue");
49 TType value = _queue.back();
56 std::lock_guard<std::mutex> lock(_mutex);
59 throw std::runtime_error(
"Trying to pop from an empty queue");
61 TType value = _queue.front();
void push_front(const TType &newElement)
void push_back(const TType &newElement)