From 3010c87008a1f4c7ce12a7a8167cd0e3bd9ca4e2 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 25 Dec 2016 21:52:52 +0100 Subject: [PATCH] CommandQueue: basic queue behaviour implemented and tested --- src/proc/control/command-queue.hpp | 12 ++++++++++-- src/proc/control/command-registry.hpp | 3 ++- tests/core/proc/control/command-queue-test.cpp | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/proc/control/command-queue.hpp b/src/proc/control/command-queue.hpp index 23e19ba55..29b611bf5 100644 --- a/src/proc/control/command-queue.hpp +++ b/src/proc/control/command-queue.hpp @@ -42,8 +42,10 @@ #define PROC_CONTROL_COMMAND_QUEUE_H #include "proc/control/command.hpp" +#include "lib/iter-stack.hpp" //#include "common/subsys.hpp" //#include "lib/depend.hpp" +#include "lib/util.hpp" //#include //#include @@ -55,6 +57,7 @@ namespace control { // using lib::Symbol; // using std::bind; + using lib::unConst; @@ -62,6 +65,7 @@ namespace control { * @todo Type-comment */ class CommandQueue + : public lib::IterQueue { public: @@ -69,14 +73,18 @@ namespace control { { } + void + clear() + { + this->stateCore().clear(); + } /* == diagnostics == */ size_t size() const { - TODO ("implement queue"); - return 0; + return unConst(this)->stateCore().size(); } bool diff --git a/src/proc/control/command-registry.hpp b/src/proc/control/command-registry.hpp index 13ab398a1..13badb616 100644 --- a/src/proc/control/command-registry.hpp +++ b/src/proc/control/command-registry.hpp @@ -134,7 +134,8 @@ namespace control { ~CommandRegistry() { - INFO (command, "Shutting down Command system..."); + if (0 < index_size()) + INFO (command, "Shutting down Command system..."); //////////////////////TICKET #295 : possibly remotely trigger Command mass suicide here.... ridx_.clear(); index_.clear(); diff --git a/tests/core/proc/control/command-queue-test.cpp b/tests/core/proc/control/command-queue-test.cpp index 8c2999f71..1bb86072e 100644 --- a/tests/core/proc/control/command-queue-test.cpp +++ b/tests/core/proc/control/command-queue-test.cpp @@ -122,7 +122,7 @@ namespace test { Command x = queue.pop(); CHECK (1 == queue.size()); - CHECK (COMMAND_1 == x.getID()); + CHECK (x == com11); queue.clear(); CHECK (0 == queue.size());