49 #ifndef STEAM_CONTROL_LOOPER_H 50 #define STEAM_CONTROL_LOOPER_H 67 using std::chrono::milliseconds;
116 using Predicate = std::function<bool(void)>;
118 bool shutdown_ =
false;
119 bool disabled_ =
false;
120 bool inChange_ =
false;
121 bool hasWork_ =
false;
122 bool isDirty_ =
false;
126 Predicate hasCommandsPending_;
131 Looper(FUN determine_commands_are_waiting)
132 : hasCommandsPending_(determine_commands_are_waiting)
140 bool isDying()
const {
return shutdown_; }
141 bool isDisabled()
const {
return disabled_ or isDying(); }
142 bool useTimeout()
const {
return isDirty_ and not isDisabled(); }
143 bool isWorking()
const {
return hasWork_ and not isDisabled(); }
144 bool idleBuild()
const {
return isDirty_ and not hasWork_; }
145 bool runBuild()
const {
return (idleBuild() or
forceBuild()) and not isDisabled(); }
146 bool isIdle()
const {
return not (isWorking() or runBuild() or isDisabled()); }
158 enableProcessing(
bool yes =
true)
191 hasWork_ = hasCommandsPending_();
192 bool proceedImmediately = isWorking() or
forceBuild() or isDying();
193 inChange_ = proceedImmediately or useTimeout();
195 if (isWorking() and not isDirty_)
197 startBuilderTimeout();
201 return proceedImmediately;
208 return not isDying();
214 if (not useTimeout())
215 return milliseconds::zero();
219 * (isDirty_ and not isWorking()? 1 : slowdownFactor())};
225 static uint slowdownFactor();
227 void startBuilderTimeout();
251 Looper::slowdownFactor()
257 Looper::startBuilderTimeout()
259 gotDirty_ = RealClock::now();
271 and maxBuildTimeout <
Offset(gotDirty_, RealClock::now());
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
const uint STEAM_DISPATCHER_BUSY_SLOWDOWN_FACTOR
Factor to slow down the latency when the command queue is not empty.
bool hasPendingChanges() const
< "check point"
const uint STEAM_DISPATCHER_BUILDER_DELAY_ms
Latency to trigger the Builder after processing command(s).
Steam-Layer implementation namespace root.
bool shallLoop() const
state fusion to control looping
bool requireAction()
state fusion to control (timed) wait
Lumiera's internal time value datatype.
void markStateProcessed()
invoking this function signals that all consequences of past state changes have been processed and ar...
static const Time NEVER
border condition marker value. NEVER >= any time value
Offset measures a distance in time.
Duration is the internal Lumiera time metric.
Encapsulated control logic for the session thread loop.
Convenience frontend to access the current raw system time.
a family of time value like entities and their relationships.
Front-end for simplified access to the current wall clock time.
static uint wakeTimeout_ms()