enforce one second loops

master
Dirk Heilig 2024-09-23 15:03:14 +02:00
parent e48da052b1
commit 16c6fe5704
1 changed files with 3 additions and 5 deletions

View File

@ -136,7 +136,9 @@ $lastGC = time();
while ($isRunning) {
$loopEnd = microtime(true) + 1;
$mqtt->loop(1000);
while (microtime(true) < $loopEnd) {
$mqtt->loop(100);
}
if ($lastGC + 60 < time()) {
logit("doing Garbage collection...");
@ -145,10 +147,6 @@ while ($isRunning) {
$lastGC = time();
}
if ($loopEnd > microtime(true)) {
usleep(intval($loopEnd - microtime(true)) * 1000000);
}
if (($news && time() - $timer > 1) || time() - $timer > 15) {
logit("Outputting ", $news ? "for changes" : "periodically");
output();