#ifndef OPENPOSE_THREAD_QUEUE_HPP #define OPENPOSE_THREAD_QUEUE_HPP #include // std::queue #include #include namespace op { template> class Queue : public QueueBase { public: explicit Queue(const long long maxSize); virtual ~Queue(); TDatums front() const; private: bool pop(TDatums& tDatums); DELETE_COPY(Queue); }; } // Implementation #include // std::is_same namespace op { template Queue::Queue(const long long maxSize) : QueueBase{maxSize} { // Check TDatums = underlying value type of TQueue typedef typename TQueue::value_type underlyingValueType; static_assert(std::is_same::value, "Error: The type of the queue must be the same as the type of the container"); } template Queue::~Queue() { } template TDatums Queue::front() const { try { const std::lock_guard lock{this->mMutex}; return this->mTQueue.front(); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return TDatums{}; } } template bool Queue::pop(TDatums& tDatums) { try { if (this->mPopIsStopped || this->mTQueue.empty()) return false; tDatums = {std::move(this->mTQueue.front())}; this->mTQueue.pop(); this->mConditionVariable.notify_one(); return true; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return false; } } COMPILE_TEMPLATE_DATUM(Queue); } #endif // OPENPOSE_THREAD_QUEUE_HPP