40 #ifndef STEAM_CONTROL_LOOPER_H 41 #define STEAM_CONTROL_LOOPER_H 58 using std::chrono::milliseconds;
107 using Predicate = std::function<bool(void)>;
109 bool shutdown_ =
false;
110 bool disabled_ =
false;
111 bool inChange_ =
false;
112 bool hasWork_ =
false;
113 bool isDirty_ =
false;
117 Predicate hasCommandsPending_;
122 Looper(FUN determine_commands_are_waiting)
123 : hasCommandsPending_(determine_commands_are_waiting)
131 bool isDying()
const {
return shutdown_; }
132 bool isDisabled()
const {
return disabled_ or isDying(); }
133 bool useTimeout()
const {
return isDirty_ and not isDisabled(); }
134 bool isWorking()
const {
return hasWork_ and not isDisabled(); }
135 bool idleBuild()
const {
return isDirty_ and not hasWork_; }
136 bool runBuild()
const {
return (idleBuild() or
forceBuild()) and not isDisabled(); }
137 bool isIdle()
const {
return not (isWorking() or runBuild() or isDisabled()); }
149 enableProcessing(
bool yes =
true)
182 hasWork_ = hasCommandsPending_();
183 bool proceedImmediately = isWorking() or
forceBuild() or isDying();
184 inChange_ = proceedImmediately or useTimeout();
186 if (isWorking() and not isDirty_)
188 startBuilderTimeout();
192 return proceedImmediately;
199 return not isDying();
205 if (not useTimeout())
206 return milliseconds::zero();
210 * (isDirty_ and not isWorking()? 1 : slowdownFactor())};
216 static uint slowdownFactor();
218 void startBuilderTimeout();
242 Looper::slowdownFactor()
248 Looper::startBuilderTimeout()
250 gotDirty_ = RealClock::now();
262 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()