[PATCH 3/3] os: refactor CheckAllTimers

Daniel Kurtz djkurtz at chromium.org
Sat Sep 22 06:28:37 PDT 2012


CheckAllTimers() is called with signals blocked.
Calling TimerForce within CheckAllTimers is inefficient because:
 (a) signals are be blocked & unblocked again
 (b) the timer list is traversed again
 (c) CheckAllTimers() ignores the return value

Instead, just call DoTimer() directly.

Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
---
 os/WaitFor.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/os/WaitFor.c b/os/WaitFor.c
index 2aab6d1..23347ec 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -355,15 +355,17 @@ WaitForSomething(int *pClientsReady)
 static void
 CheckAllTimers(void)
 {
+    OsTimerPtr *prev;
     OsTimerPtr timer;
     CARD32 now;
 
  start:
     now = GetTimeInMillis();
 
-    for (timer = timers; timer; timer = timer->next) {
+    for (prev = &timers; *prev; prev = &(*prev)->next) {
+        timer = *prev;
         if (timer->expires - now > timer->delta + 250) {
-            TimerForce(timer);
+            DoTimer(timer, now, prev);
             goto start;
         }
     }
-- 
1.7.7.3



More information about the xorg-devel mailing list