ProcDispatcher: skeleton of the processing loop
including a draft of the Looper control component and the invocation of the object monitor for waiting on condition var
This commit is contained in:
parent
00077d0431
commit
7b860947b1
3 changed files with 138 additions and 6 deletions
|
|
@ -58,10 +58,22 @@ namespace control {
|
|||
// using lib::Symbol;
|
||||
// using std::bind;
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @todo this value should be retrieved from configuration ////////////////////////////////TICKET #1052 : access application configuration
|
||||
* @see Looper::establishWakeTimeout()
|
||||
*/
|
||||
const uint PROC_DISPATCHER_BUILDER_DELAY_ms = 50;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo Type-comment
|
||||
* @todo write Type-comment (WIP 12/2016)
|
||||
*
|
||||
* @warning the Looper _is not threadsafe,_
|
||||
* since it is intended to be run exclusively from
|
||||
* the Session working thread.
|
||||
* @see DispatcherLoop::run()
|
||||
*/
|
||||
class Looper
|
||||
{
|
||||
|
|
@ -70,6 +82,37 @@ namespace control {
|
|||
Looper()
|
||||
{ }
|
||||
|
||||
/* == working state == */
|
||||
|
||||
bool isWorking() const { return false; }
|
||||
bool isIdle() const { return false; }
|
||||
bool needBuild() const { return false; }
|
||||
bool isDisabled() const { return false; }
|
||||
bool isDying() const { return false; }
|
||||
|
||||
|
||||
/** state fusion to control (timed) wait */
|
||||
bool
|
||||
requireAction()
|
||||
{
|
||||
return isWorking()
|
||||
or needBuild()
|
||||
or isDying();
|
||||
}
|
||||
|
||||
/** state fusion to control looping */
|
||||
bool
|
||||
shallLoop() const
|
||||
{
|
||||
return not isDying();
|
||||
}
|
||||
|
||||
ulong
|
||||
getTimeout() const
|
||||
{
|
||||
static uint wakeTimeout_ms = establishWakeTimeout();
|
||||
return wakeTimeout_ms;
|
||||
}
|
||||
|
||||
|
||||
/* == diagnostics == */
|
||||
|
|
@ -77,10 +120,28 @@ namespace control {
|
|||
// size_t size() const ;
|
||||
// bool empty() const ;
|
||||
|
||||
private:
|
||||
static uint establishWakeTimeout();
|
||||
};
|
||||
////////////////TODO 12/16 currently just fleshing out the API....
|
||||
|
||||
|
||||
/** @internal establish the typical timeout for idle sleep.
|
||||
* When the ProcDispatcher has no work to do, it needs to wake up regularly
|
||||
* for a checkpoint, to determine if the Builder needs to be triggered or
|
||||
* the shutdown-flag be checked. So the period established here defines
|
||||
* some kind of minimal reaction especially for the builder, so to ensure
|
||||
* that further commands trickling in get a chance to be enqueued before
|
||||
* the builder run effectively blocks command processing. Add to this
|
||||
* the typical average running time of the builder, to get the reaction
|
||||
* period visible to the user as update response delay within the UI.
|
||||
* @todo find a way how to retrieve this value from application config! ////////////////////TICKET #1052 : access application configuration
|
||||
*/
|
||||
uint
|
||||
Looper::establishWakeTimeout()
|
||||
{
|
||||
return PROC_DISPATCHER_BUILDER_DELAY_ms;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace proc::control
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace control {
|
|||
{
|
||||
bool canDispatch_{false};
|
||||
bool blocked_ {false};
|
||||
bool mustHalt_ {false};
|
||||
bool mustHalt_ {false}; /////////////////TODO this flag shall be relocated into the Looper!
|
||||
|
||||
unique_ptr<SessionCommandService> commandService_;
|
||||
|
||||
|
|
@ -134,8 +134,16 @@ namespace control {
|
|||
string errorMsg;
|
||||
try
|
||||
{
|
||||
TODO ("actually do something in the loop"); /////////////////////////////////////////TODO *** THIS NEXT TO IMPLEMENT !!!! ***
|
||||
sleep(2);
|
||||
while (looper_.shallLoop())
|
||||
{
|
||||
awaitAction();
|
||||
if (looper_.isDying()) break;
|
||||
if (looper_.needBuild())
|
||||
startBuilder();
|
||||
else
|
||||
if (looper_.isWorking())
|
||||
processCommands();
|
||||
}
|
||||
}
|
||||
catch (lumiera::Error& problem)
|
||||
{
|
||||
|
|
@ -146,20 +154,42 @@ namespace control {
|
|||
{
|
||||
errorMsg = string{lumiera_error()};
|
||||
}
|
||||
// now leave the Session thread...
|
||||
// send notification of subsystem shutdown
|
||||
sigTerm (&errorMsg);
|
||||
}
|
||||
|
||||
void
|
||||
awaitAction()
|
||||
{
|
||||
Lock(this).wait(looper_,
|
||||
&Looper::requireAction,
|
||||
looper_.getTimeout());
|
||||
}
|
||||
|
||||
void
|
||||
processCommands()
|
||||
{
|
||||
UNIMPLEMENTED ("pull commands from the queue and dispatch them");
|
||||
}
|
||||
|
||||
void
|
||||
startBuilder()
|
||||
{
|
||||
UNIMPLEMENTED ("start the Proc-Builder to recalculate render nodes network");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** storage for Singleton access */
|
||||
lib::Depend<ProcDispatcher> ProcDispatcher::instance;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** */
|
||||
bool
|
||||
ProcDispatcher::start (Subsys::SigTerm termNotification)
|
||||
|
|
|
|||
|
|
@ -11048,13 +11048,54 @@
|
|||
</node>
|
||||
<node CREATED="1481778565298" ID="ID_1803510423" MODIFIED="1481778569181" TEXT="Schleifen-Logik">
|
||||
<node CREATED="1481778570153" ID="ID_6904207" MODIFIED="1481778579395" TEXT="beruht auf CondVar / wait"/>
|
||||
<node CREATED="1481831352239" ID="ID_947882756" MODIFIED="1481831357242" TEXT="Looper-Hilfskomponente"/>
|
||||
<node CREATED="1481831372092" ID="ID_411828431" MODIFIED="1481832034056" TEXT="muß...">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1481831398297" ID="ID_1100709659" MODIFIED="1481831407731" TEXT="aufwachen wenn Commands anstehen"/>
|
||||
<node CREATED="1481831722406" ID="ID_462123533" MODIFIED="1481831730937" TEXT="aufwachen wenn Checkpoint"/>
|
||||
<node CREATED="1481831408415" ID="ID_1091888781" MODIFIED="1481831424193" TEXT="aufwachen bei Shutdown"/>
|
||||
<node CREATED="1481831432220" ID="ID_1256743195" MODIFIED="1481831446206" TEXT="Shutdown-Flag verwalten"/>
|
||||
<node CREATED="1481831886448" ID="ID_1022163658" MODIFIED="1481832025050" TEXT="Betriebszustand">
|
||||
<icon BUILTIN="info"/>
|
||||
<node CREATED="1481831945472" ID="ID_756400184" MODIFIED="1481831947772" TEXT="arbeitend"/>
|
||||
<node CREATED="1481831948240" ID="ID_349500680" MODIFIED="1481832004796" TEXT="Leerlauf"/>
|
||||
<node CREATED="1481831950160" ID="ID_602481733" MODIFIED="1481831962578" TEXT="gesperrt"/>
|
||||
<node CREATED="1481831965253" ID="ID_1644273707" MODIFIED="1481832013139" TEXT="sterbend"/>
|
||||
</node>
|
||||
<node CREATED="1481831638089" ID="ID_209292609" MODIFIED="1481831840636" TEXT="Builder steuern">
|
||||
<arrowlink COLOR="#5242a4" DESTINATION="ID_1311208726" ENDARROW="Default" ENDINCLINATION="2;-45;" ID="Arrow_ID_313252247" STARTARROW="None" STARTINCLINATION="-186;-13;"/>
|
||||
</node>
|
||||
<node CREATED="1481831642376" ID="ID_1301681872" MODIFIED="1481831650435" TEXT="Checkpoint bieten"/>
|
||||
<node CREATED="1481831747042" ID="ID_134003952" MODIFIED="1481831788672" TEXT="sperrbar sein">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...und dann nur noch
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
auf Shutdown reagieren
|
||||
</li>
|
||||
<li>
|
||||
mitbekommen wenn die Sperre aufgehoben wird
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1481778590790" ID="ID_1748096848" MODIFIED="1481826297245" TEXT="Anhalten">
|
||||
<linktarget COLOR="#f70841" DESTINATION="ID_1748096848" ENDARROW="Default" ENDINCLINATION="-353;-77;" ID="Arrow_ID_506637666" SOURCE="ID_1844558240" STARTARROW="None" STARTINCLINATION="-200;38;"/>
|
||||
<node CREATED="1481778666820" ID="ID_1860590145" MODIFIED="1481778688685" TEXT="trigger-Variable mustHalt_"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481778708207" HGAP="48" ID="ID_1311208726" MODIFIED="1481828597227" TEXT="Builder-Steuerung" VSHIFT="-5">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1481778708207" HGAP="48" ID="ID_1311208726" MODIFIED="1481831819823" TEXT="Builder-Steuerung" VSHIFT="-5">
|
||||
<linktarget COLOR="#5242a4" DESTINATION="ID_1311208726" ENDARROW="Default" ENDINCLINATION="2;-45;" ID="Arrow_ID_313252247" SOURCE="ID_209292609" STARTARROW="None" STARTINCLINATION="-186;-13;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1481828478741" ID="ID_1706868067" MODIFIED="1481828497838" TEXT="Hysterese"/>
|
||||
<node CREATED="1481828498618" ID="ID_321199314" MODIFIED="1481828519539" TEXT="nach neuem Command, mit kleiner Verzögerung"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue