introduce CommandDispatch interface
this allows to let the DispatcherLoop actually serve as implementation facility for the SessionCommandService
This commit is contained in:
parent
1ec883787a
commit
4d45dfd4be
3 changed files with 39 additions and 29 deletions
|
|
@ -2,7 +2,7 @@
|
|||
COMMAND-DISPATCH.hpp - Interface to enqueue and dispatch command messages
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2009, Hermann Vosseler <Ichthyostega@web.de>
|
||||
2016, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
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 <memory>
|
||||
//#include <memory>
|
||||
//#include <functional>
|
||||
|
||||
|
||||
|
|
@ -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<DispatcherLoop> runningLoop_;
|
||||
bool active_{false};
|
||||
|
||||
|
||||
public:
|
||||
static lib::Depend<ProcDispatcher> 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....
|
||||
|
|
|
|||
|
|
@ -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<RecursiveLock_Waitable>
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue