revise Timer phase reset

This commit is contained in:
Michael Davidsaver
2025-12-03 18:23:59 -08:00
committed by mdavidsaver
parent b4114589ff
commit 9ec9a526f5

View File

@@ -118,18 +118,6 @@ void Timer::run()
work->processing = true;
queue.pop_front();
if(work->period > 0.0 && alive && !work->cancelled) {
/*
* If the distance between the time now and the time
* the timer was to run is more than the period move
* the timer's run time to now and avoid the timer
* spinning issuing callbacks for missed timer events
*/
if ((now - work->timeToRun) > work->period) {
work->timeToRun = now;
}
}
{
epicsGuardRelease<epicsMutex> U(G);
@@ -139,6 +127,12 @@ void Timer::run()
work->processing = false;
if(work->period > 0.0 && alive && !work->cancelled) {
if(waitfor <= -work->period) {
// Periodic timer phase has fallen behind by at least one full period.
// Could be due to previous slow jobs, or a system time jump forward.
// Reset the phase.
work->timeToRun = now = epicsTime::getCurrent();
}
work->timeToRun += work->period;
addElement(work);
}