diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp index c068af25d8dec9e449a4b662de8c527c962214ae..1dd0919bbbb329273beaa4ccc9bee11732b6246c 100644 --- a/components/common/cpp/src/timer.cpp +++ b/components/common/cpp/src/timer.cpp @@ -61,10 +61,9 @@ static void waitTimePoint() { } // Still lots of time so do some idle jobs - while (msdelay >= 10 && sincelast != mspf) { - for (auto &j : jobs[kTimerIdle10]) { - j.job(now); - } + auto idle_job = jobs[kTimerIdle10].begin(); + while (idle_job != jobs[kTimerIdle10].end() && msdelay >= 10 && sincelast != mspf) { + (*idle_job++).job(now); now = get_time(); msdelay = mspf - (now % mspf); }