From 3c02a51a794a2a224f1a2850071225a460b5445c Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 21 Aug 2019 13:47:16 +0300
Subject: [PATCH] Only do one idle job at a time

---
 components/common/cpp/src/timer.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp
index c068af25d..1dd0919bb 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);
 	}
-- 
GitLab