implement activated state

need to keep state variables on both levels,
since the session manager (lifecycle) "opens" the session
for external access by starting the dispatcher; it may well happen
thus that the session starts up, while the *session subsystem*
is not(yet) started
This commit is contained in:
Fischlurch 2016-12-14 04:57:08 +01:00
parent a853851447
commit 479f4170c2
3 changed files with 87 additions and 12 deletions

View file

@ -45,6 +45,9 @@ namespace control {
: ThreadJoinable
, public Sync<RecursiveLock_Waitable>
{
bool canDispatch_{false};
bool blocked_ {false};
public:
DispatcherLoop (Subsys::SigTerm notification)
: ThreadJoinable("Lumiera Session"
@ -58,7 +61,25 @@ namespace control {
this->join();
INFO (session, "Proc-Dispatcher stopped.");
}
void
activateCommandProecssing()
{
Lock sync(this);
canDispatch_ = true;
INFO (command, "Session command processing activated.");
TODO ("implement command processing queue");
}
void
deactivateCommandProecssing()
{
Lock sync(this);
canDispatch_ = false;
INFO (command, "Session command interface closed.");
TODO ("implement command processing queue");
}
private:
void
run (Subsys::SigTerm sigTerm)
@ -106,7 +127,9 @@ namespace control {
runningLoop_.reset();
termNotification(problemMessage);
}));
if (active_)
runningLoop_->activateCommandProecssing();
return true;
}
@ -129,13 +152,21 @@ namespace control {
}
/** */
/** activate processing of enqueued session commands.
* @remarks command processing serves as public external interface
* to the session. This call is used by the session lifecycle (SessManagerImpl)
* when the session is brought up; any other invocation runs danger to mess up
* the session lifecycle state and process commands on a deconfigured session.
* In case the dispatcher loop is not actually running, the activation state
* is stored and applied accordingly later, when the loop is fired up.
*/
void
ProcDispatcher::activate()
{
Lock sync(this);
INFO (command, "Session command processing activated."); ///////////////TODO only emit these log messages when processing is *really* started/stopped
TODO ("implement command processing queue");
active_ = true;
if (runningLoop_)
runningLoop_->activateCommandProecssing();
}
@ -143,8 +174,9 @@ namespace control {
ProcDispatcher::deactivate()
{
Lock sync(this);
INFO (command, "Session command interface closed.");
TODO ("implement command processing queue");
active_ = false;
if (runningLoop_)
runningLoop_->deactivateCommandProecssing();
}
@ -152,7 +184,7 @@ namespace control {
ProcDispatcher::clear()
{
Lock sync(this);
if (!empty())
if (not empty())
WARN (command, "DISCARDING pending Session commands.");
TODO ("implement command processing queue");
}

View file

@ -64,6 +64,7 @@ namespace control {
: public lib::Sync<>
{
unique_ptr<DispatcherLoop> runningLoop_;
bool active_{false};
public:

View file

@ -222,8 +222,7 @@
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481509921211" ID="ID_1515469097" MODIFIED="1481599502388" TEXT="TODO: Session-Subsystem implementieren (#318)">
<icon BUILTIN="pencil"/>
<node CREATED="1481599413419" ID="ID_673133356" MODIFIED="1481599420290" TEXT="Ticket #318"/>
<node CREATED="1481599421021" ID="ID_461768132" MODIFIED="1481599492544" TEXT="Locking kl&#xe4;ren">
<icon BUILTIN="pencil"/>
<node CREATED="1481599421021" ID="ID_461768132" MODIFIED="1481686898425" TEXT="Locking kl&#xe4;ren">
<node CREATED="1481684383530" ID="ID_236117" MODIFIED="1481684451657" TEXT="zwei unabh&#xe4;ngige Locks">
<icon BUILTIN="yes"/>
<node CREATED="1481684391921" ID="ID_138369898" MODIFIED="1481684442846" TEXT="Front-End">
@ -257,13 +256,56 @@
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
<node CREATED="1481599430804" ID="ID_1105415989" MODIFIED="1481599438887" TEXT="Forwarding-Operationen implementieren"/>
<node CREATED="1481599594399" ID="ID_1017459823" MODIFIED="1481599602601" TEXT="entscheiden, wer die Session &#xf6;ffnet">
<node CREATED="1481599430804" ID="ID_1105415989" MODIFIED="1481599438887" TEXT="Forwarding-Operationen implementieren">
<node CREATED="1481686902156" ID="ID_1526215617" MODIFIED="1481686910633" TEXT="aktivieren /deaktivieren">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481686911938" ID="ID_17287395" MODIFIED="1481686919619" TEXT="stoppen">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node CREATED="1481599594399" ID="ID_1017459823" MODIFIED="1481687087609" TEXT="entscheiden, wer die Session &#xf6;ffnet">
<icon BUILTIN="button_ok"/>
<node CREATED="1481686982097" ID="ID_1925999031" MODIFIED="1481687002238" TEXT="passiert on demand">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
...wenn jemand zugreift
</p>
</body>
</html>
</richcontent>
</node>
<node CREATED="1481599603757" ID="ID_812618450" MODIFIED="1481599612320" TEXT="Operation auf dem SessionManager"/>
<node CREATED="1481599612812" ID="ID_1970476027" MODIFIED="1481599618598" TEXT="der ist Singleton"/>
<node CREATED="1481599626194" ID="ID_1815350592" MODIFIED="1481599638105" TEXT="wenn Session &#xf6;ffnet, wird der Dispatcher aktiviert">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1481687005813" ID="ID_1108477992" MODIFIED="1481687081246" TEXT="Entscheidung: Sesion-lifecycle und Dispatcher sind unabh&#xe4;ngig">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
grundlegende Design-Enscheidung
</p>
<ul>
<li>
wir haben Komponenten mit Dependency-Injection
</li>
<li>
da beide Komponenten nur nach ihren eigenen Hinsichten funktionieren,<br />wird das System insgesamt einfacher
</li>
</ul>
</body>
</html>
</richcontent>
<icon BUILTIN="yes"/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481510231986" ID="ID_45803267" MODIFIED="1481510243425" TEXT="TODO: dort SessionCommandService instantiieren">