Scheduler: consider wiring of Load-Controller

...and general questions of component design and coupling.
Decided to go for explicit configuration points by functor.
This commit is contained in:
Fischlurch 2023-10-23 21:51:16 +02:00
parent 69fb77246e
commit 08c13ed6fe
4 changed files with 160 additions and 15 deletions

View file

@ -78,13 +78,14 @@
#include "lib/error.hpp"
//#include "vault/gear/block-flow.hpp"
#include "vault/gear/activity-lang.hpp"
//#include "vault/gear/activity-lang.hpp"
//#include "lib/symbol.hpp"
#include "lib/nocopy.hpp"
//#include "lib/util.hpp"
//#include <string>
#include <chrono>
#include <utility>
namespace vault{
@ -96,8 +97,9 @@ namespace gear {
using lib::time::Time;
using lib::time::FSecs;
using lib::time::TimeVar;
using lib::time::Offset;
using lib::time::TimeValue;
using lib::time::Duration;
using lib::time::Offset;
using std::chrono_literals::operator ""ms;
using std::chrono_literals::operator ""us;
@ -125,16 +127,26 @@ namespace gear {
class LoadController
: util::NonCopyable
{
BlockFlowAlloc& allocator_;
TimeVar tendedHead_{Time::ANYTIME};
public:
struct Wiring
{
size_t maxCapacity{2};
};
explicit
LoadController (BlockFlowAlloc& blockFlow)
: allocator_{blockFlow}
LoadController (Wiring&& wiring)
: wiring_{std::move (wiring)}
{ }
LoadController()
: LoadController{Wiring{}}
{ }
private:
Wiring wiring_;
TimeVar tendedHead_{Time::ANYTIME};
public:
/**
* did we already tend for the indicated next head time?

View file

@ -113,7 +113,7 @@ namespace gear {
, layer2_{}
, workForce_{Setup{IDLE_WAIT, DISMISS_CYCLES, *this}}
, activityLang_{activityAllocator}
, loadControl_{activityAllocator}
, loadControl_{connectMonitoring()}
, engineObserver_{engineObserver}
{ }
@ -219,6 +219,16 @@ namespace gear {
}
};
/** @internal connect state signals for use by the LoadController */
LoadController::Wiring
connectMonitoring()
{
LoadController::Wiring setup;
setup.maxCapacity = work::Config::COMPUTATION_CAPACITY;
return setup;
}
/** @internal expose a binding for Activity execution */
class ExecutionCtx;
};

View file

@ -78,8 +78,7 @@ namespace test {
void
simpleUsage()
{
BlockFlowAlloc bFlow;
LoadController ctrl{bFlow};
LoadController ctrl;
}
@ -126,8 +125,7 @@ namespace test {
void
tendNextActivity()
{
BlockFlowAlloc bFlow;
LoadController lctrl{bFlow};
LoadController lctrl;
Time t1{1,0};
Time t2{2,0};
@ -172,8 +170,7 @@ namespace test {
void
classifyCapacity()
{
BlockFlowAlloc bFlow;
LoadController lctrl{bFlow};
LoadController lctrl;
Time next{0,10};

View file

@ -81973,6 +81973,36 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1698019216343" ID="ID_1018117763" MODIFIED="1698019225152" TEXT="BlockFlow wird eine externe Komponente"/>
<node CREATED="1698019231611" ID="ID_1147870240" MODIFIED="1698019236491" TEXT="EngineObserver ebenso"/>
<node CREATED="1698019237891" ID="ID_323443926" MODIFIED="1698019244558" TEXT="alles andere wird Teil vom Scheduler"/>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1698082299413" ID="ID_1968424043" MODIFIED="1698082741711" TEXT="Problem der Verdrahtung">
<arrowlink COLOR="#d5196d" DESTINATION="ID_1036009502" ENDARROW="Default" ENDINCLINATION="-219;-13;" ID="Arrow_ID_435126264" STARTARROW="None" STARTINCLINATION="-105;193;"/>
<icon BUILTIN="messagebox_warning"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1698082309174" ID="ID_1582335311" MODIFIED="1698082335844" TEXT="dieses Problem zieht sich durch den ganzen Scheduler...">
<icon BUILTIN="smiley-oh"/>
</node>
<node CREATED="1698082341487" ID="ID_689287390" MODIFIED="1698082650781" TEXT="Situationen und m&#xf6;gliche L&#xf6;sungen liegen dicht beieinander, aber...">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
...unterscheiden sich doch im Detail
</p>
<ul>
<li>
einmal ist es der Scheduler selber, dessen Funktionalit&#228;t abstrahiert als ExecutionCtx bereitzustellen ist
</li>
<li>
die WorkForce hingegen ist konzeptionell selbst&#228;ndig, wird aber vom Scheduler &#252;bernommen und gezielt parametrisiert, einschlie&#223;lich der Abstraktion <font face="Monospaced" color="#8a3ae2">doWork()</font>, welche dann doch vom Scheduler selbst zustammengestellt wird
</li>
<li>
nochmal anders ist die Situation beim LoadController, der so etwas wie die Steuerzentrale darstellt: <i>konzeptionell</i>&#160;ist er total vom Scheduler abh&#228;ngig, aber seine Implementierung ist <i>entkoppelt,</i>&#160; wiewohl in beide Richtungen verdrahtet mit wechselseitiger Abh&#228;ngigkeit. In diesem Fall mu&#223; also ein <b>Abh&#228;ngigkeitszyklus durchbrochen </b>werden
</li>
</ul>
</body>
</html></richcontent>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1693841227130" ID="ID_1537960830" MODIFIED="1697818566052" TEXT="WorkForce einbinden">
<arrowlink COLOR="#397cb2" DESTINATION="ID_987966047" ENDARROW="Default" ENDINCLINATION="-962;-41;" ID="Arrow_ID_818972822" STARTARROW="None" STARTINCLINATION="-609;73;"/>
@ -82227,6 +82257,84 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1697808322602" ID="ID_1787549088" MODIFIED="1697808340997" TEXT="Entwickelt sich wohl in Richtung einer Steuerzentrale">
<icon BUILTIN="messagebox_warning"/>
</node>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1698082672886" ID="ID_1036009502" MODIFIED="1698082741711" TEXT="bidirektional mit dem Scheduler zu verdrahten">
<linktarget COLOR="#d5196d" DESTINATION="ID_1036009502" ENDARROW="Default" ENDINCLINATION="-219;-13;" ID="Arrow_ID_435126264" SOURCE="ID_1968424043" STARTARROW="None" STARTINCLINATION="-105;193;"/>
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1698083262975" ID="ID_1385142213" MODIFIED="1698083284540" TEXT="bidirektional &#x27f9; Abh&#xe4;ngigkeits-Zyklus aufbrechen">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1698083295483" ID="ID_1606138582" MODIFIED="1698083328186" TEXT="Annahmen f&#xfc;r den Betrieb">
<node CREATED="1698083330598" ID="ID_328457875" MODIFIED="1698083406903" TEXT="nutzlose Indirektionen vermeiden">
<icon BUILTIN="yes"/>
</node>
<node CREATED="1698083351995" ID="ID_1452847242" MODIFIED="1698083404662" TEXT="l&#xe4;uft jedoch nicht auf h&#xf6;chster Performance-Stufe">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1698083371477" ID="ID_1967106906" MODIFIED="1698083396899" TEXT="alle Mutationen implizieren Grooming-Modus">
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1698083418163" ID="ID_859036076" MODIFIED="1698083432553" TEXT="L&#xf6;sung: Hilfsklasse mit Funktoren">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1698090000881" ID="ID_713507066" MODIFIED="1698090231201">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
hier k&#246;nnte man <i>named arguments </i>gebrauchen....
</p>
</body>
</html></richcontent>
<arrowlink COLOR="#967b86" DESTINATION="ID_29991404" ENDARROW="Default" ENDINCLINATION="-1293;117;" ID="Arrow_ID_152389560" STARTARROW="None" STARTINCLINATION="-2574;139;"/>
<icon BUILTIN="smily_bad"/>
</node>
<node CREATED="1698090246167" ID="ID_719284884" MODIFIED="1698090309744">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
Parametrisierung: maxCapacity = <font face="Monospaced" color="#868686">work::Config::</font><font face="Monospaced" color="#3f2c83">COMPUTATION_CAPACITY</font>
</p>
</body>
</html>
</richcontent>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1698090324855" ID="ID_1784536173" MODIFIED="1698090336812" TEXT="Zugriff auf BlockFlow-Auslastung">
<icon BUILTIN="hourglass"/>
</node>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1698090346359" ID="ID_709981296" MODIFIED="1698090367733" TEXT="wie weit treibt man das sinnvollerweise?">
<font NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="help"/>
<node CREATED="1698090381330" ID="ID_1787407613" MODIFIED="1698090452668" TEXT="Grooming-Behandlung hier&#xfc;ber integrieren?">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
schwierige Frage....
</p>
<ul>
<li>
man w&#252;rde eine subtile Falle vermeiden
</li>
<li>
man w&#252;rde point-and-shot-API bekommen
</li>
<li>
aber eben auch eine ganz starke Kopplung auf Implementierungsdetails
</li>
</ul>
</body>
</html></richcontent>
</node>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1697808351773" ID="ID_1501083047" MODIFIED="1697808428660" TEXT="Leistungen">
<icon BUILTIN="info"/>
<icon BUILTIN="pencil"/>
@ -95736,6 +95844,24 @@ class Something
<icon BUILTIN="info"/>
</node>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1698089401358" FOLDED="true" ID="ID_29991404" MODIFIED="1698090231201" TEXT="&#xd83d;&#xdec7; Wunsch: named Arguments">
<linktarget COLOR="#967b86" DESTINATION="ID_29991404" ENDARROW="Default" ENDINCLINATION="-1293;117;" ID="Arrow_ID_152389560" SOURCE="ID_713507066" STARTARROW="None" STARTINCLINATION="-2574;139;"/>
<icon BUILTIN="hourglass"/>
<node CREATED="1698089412372" ID="ID_1935249167" MODIFIED="1698089457778" TEXT="hat C++ nicht">
<node CREATED="1698089458669" ID="ID_1363045776" MODIFIED="1698089470760" TEXT="weil des dem Plattform-Konzept/ABI widerspricht"/>
<node CREATED="1698089471354" ID="ID_1708742685" MODIFIED="1698089505338" TEXT="weil es bisher nicht gelungen ist, eine unproblematische L&#xf6;sung zu schaffen">
<node COLOR="#5b280f" CREATED="1698089623891" ID="ID_851236025" LINK="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4172.htm" MODIFIED="1698089635023" TEXT=" N4172: Named arguments (gescheitert)">
<icon BUILTIN="button_cancel"/>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1698089648556" ID="ID_1884819642" LINK="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1229r0.html" MODIFIED="1698089664123" TEXT="P1229: Labelled Parameters (in Diskussion/Spezifikation)">
<icon BUILTIN="hourglass"/>
</node>
</node>
</node>
<node CREATED="1698089508382" ID="ID_77108316" LINK="https://pdimov.github.io/blog/2020/09/07/named-parameters-in-c20/" MODIFIED="1698089771312" TEXT="Workaround(seit C++20): die &#xbb;designated initializers&#xab; aus C99 nutzen"/>
<node CREATED="1698089910225" ID="ID_1931488391" LINK="https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/" MODIFIED="1698089942787" TEXT="Typsystem + variadic Templates: &#xbb;strong Types&#xab;"/>
<node CREATED="1698089963610" ID="ID_1710977423" MODIFIED="1698089968637" TEXT="Builder"/>
</node>
</node>
<node CREATED="1687648927947" ID="ID_1380476359" MODIFIED="1687648930939" TEXT="Library">
<node CREATED="1687648934225" ID="ID_614037719" MODIFIED="1687648936717" TEXT="Container">