diff --git a/src/proc/control/command-dispatch.hpp b/src/proc/control/command-dispatch.hpp index 9fc3de1e9..a36e639a4 100644 --- a/src/proc/control/command-dispatch.hpp +++ b/src/proc/control/command-dispatch.hpp @@ -2,7 +2,7 @@ COMMAND-DISPATCH.hpp - Interface to enqueue and dispatch command messages Copyright (C) Lumiera.org - 2009, Hermann Vosseler + 2016, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -23,7 +23,9 @@ /** @file command-dispatch.hpp ** Interface to abstract the DispatcherLoop's ability to handle command messages. - ** //TODO + ** //TODO + ** + ** @todo WIP-WIP as of 12/2016 ** ** @see proc-dispatcher.hpp ** @see session-command-service.hpp @@ -36,12 +38,11 @@ #ifndef PROC_CONTROL_COMMAND_DISPATCH_H #define PROC_CONTROL_COMMAND_DISPATCH_H -//#include "lib/symbol.hpp" -#include "common/subsys.hpp" -#include "lib/depend.hpp" -#include "lib/sync.hpp" +#include "lib/error.hpp" ////////TODO needed? +//#include "common/subsys.hpp" +//#include "lib/depend.hpp" -#include +//#include //#include @@ -50,40 +51,26 @@ namespace proc { namespace control { // using lib::Symbol; - using std::unique_ptr; // using std::bind; - using lumiera::Subsys; - class DispatcherLoop; - /** * @todo Type-comment */ - class ProcDispatcher - : public lib::Sync<> + class CommandDispatch { - unique_ptr runningLoop_; - bool active_{false}; - public: - static lib::Depend instance; + virtual ~CommandDispatch() { } ///< this is an interface - bool start (Subsys::SigTerm); - bool isRunning(); - void requestStop(); - - void activate(); - void deactivate(); - void clear(); + virtual void clear() =0; /////TODO placeholder code /* == diagnostics == */ // size_t size() const ; - bool empty() const ; +// bool empty() const ; }; ////////////////TODO currently just fleshing out the API.... diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index 83b8d82c6..ddeafc1b8 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -25,6 +25,7 @@ #include "lib/error.hpp" #include "include/logging.h" #include "proc/control/proc-dispatcher.hpp" +#include "proc/control/command-dispatch.hpp" #include "proc/mobject/session.hpp" #include "backend/thread-wrapper.hpp" //#include "proc/mobject/mobject-ref.hpp" @@ -43,6 +44,7 @@ namespace control { class DispatcherLoop : ThreadJoinable + , public CommandDispatch , public Sync { bool canDispatch_{false}; @@ -80,6 +82,23 @@ namespace control { TODO ("implement command processing queue"); } + + /* === CommandDispatch interface === */ + + void + clear() override + { + Lock sync(this); + UNIMPLEMENTED ("clear the queue"); + } + + size_t + size() const + { + TODO ("implement command processing queue"); + return 0; + } + private: void run (Subsys::SigTerm sigTerm) @@ -185,8 +204,11 @@ namespace control { { Lock sync(this); if (not empty()) - WARN (command, "DISCARDING pending Session commands."); - TODO ("implement command processing queue"); + { + WARN (command, "DISCARDING pending Session commands."); + REQUIRE (runningLoop_); + runningLoop_->clear(); + } } @@ -194,8 +216,8 @@ namespace control { ProcDispatcher::empty() const { Lock sync(this); - TODO ("implement command processing queue"); - return true; + return not runningLoop_ + or 0 == runningLoop_->size(); } diff --git a/src/proc/control/session-command-service.hpp b/src/proc/control/session-command-service.hpp index da20b9e76..a15b97bb3 100644 --- a/src/proc/control/session-command-service.hpp +++ b/src/proc/control/session-command-service.hpp @@ -42,6 +42,7 @@ #include "include/session-command-facade.h" +#include "proc/control/command-dispatch.hpp" #include "common/instancehandle.hpp" #include "lib/singleton-ref.hpp"