From 6f3d9a6c82678d7052010b81fbcf223144062244 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Fri, 31 Jul 2015 21:28:14 -0400 Subject: [PATCH] visual process template tweaks, full() logic error fix --- src/process/ScopeVisualProcessor.h | 2 +- src/process/VisualProcessor.h | 26 +++++++++++++------------- src/util/ThreadQueue.h | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/process/ScopeVisualProcessor.h b/src/process/ScopeVisualProcessor.h index e8d411b..44262ab 100644 --- a/src/process/ScopeVisualProcessor.h +++ b/src/process/ScopeVisualProcessor.h @@ -11,7 +11,7 @@ public: typedef ThreadQueue ScopeRenderDataQueue; -class ScopeVisualProcessor : public VisualProcessor { +class ScopeVisualProcessor : public VisualProcessor { protected: virtual void process() { if (isOutputEmpty()) { diff --git a/src/process/VisualProcessor.h b/src/process/VisualProcessor.h index f6c876e..f84c32d 100644 --- a/src/process/VisualProcessor.h +++ b/src/process/VisualProcessor.h @@ -5,30 +5,30 @@ #include "IOThread.h" #include -template +template class VisualProcessor { public: virtual ~VisualProcessor() { } - void setInput(InputQueueType *vis_in) { + void setInput(ThreadQueue *vis_in) { busy_update.lock(); input = vis_in; busy_update.unlock(); } - void attachOutput(OutputQueueType *vis_out) { + void attachOutput(ThreadQueue *vis_out) { // attach an output queue busy_update.lock(); outputs.push_back(vis_out); busy_update.unlock(); } - void removeOutput(OutputQueueType *vis_out) { + void removeOutput(ThreadQueue *vis_out) { // remove an output queue busy_update.lock(); - typename std::vector::iterator i = std::find(outputs.begin(), outputs.end(), vis_out); + typename std::vector *>::iterator i = std::find(outputs.begin(), outputs.end(), vis_out); if (i != outputs.end()) { outputs.erase(i); } @@ -79,23 +79,23 @@ protected: return false; } - InputQueueType *input; - std::vector outputs; - typename std::vector::iterator outputs_i; + ThreadQueue *input; + std::vector *> outputs; + typename std::vector *>::iterator outputs_i; std::mutex busy_update; }; -template -class VisualDataDistributor : public VisualProcessor { +template +class VisualDataDistributor : public VisualProcessor { protected: void process() { - while (!VisualProcessor::input->empty()) { + while (!VisualProcessor::input->empty()) { ReferenceCounter *inp; - VisualProcessor::input->pop(inp); + VisualProcessor::input->pop(inp); if (inp) { - VisualProcessor::distribute(inp); + VisualProcessor::distribute(inp); } } } diff --git a/src/util/ThreadQueue.h b/src/util/ThreadQueue.h index 67247a6..8ba5e0a 100644 --- a/src/util/ThreadQueue.h +++ b/src/util/ThreadQueue.h @@ -212,12 +212,12 @@ public: } /** - * Check if the queue is empty. - * \return true if queue is empty. + * Check if the queue is full. + * \return true if queue is full. */ bool full() const { std::lock_guard < std::mutex > lock(m_mutex); - return m_queue.size() >= m_max_num_items; + return (m_max_num_items != 0) && (m_queue.size() >= m_max_num_items); } /**