[maemo-commits] [maemo-commits] r19289 - in projects/haf/branches/clutter: . starvation/clutter/x11

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Sep 3 19:11:51 EEST 2009
Author: aendrodi
Date: 2009-09-03 19:11:24 +0300 (Thu, 03 Sep 2009)
New Revision: 19289

Added:
   projects/haf/branches/clutter/starvation/
Modified:
   projects/haf/branches/clutter/starvation/clutter/x11/clutter-event-x11.c
Log:
pure no-startvation patch


Copied: projects/haf/branches/clutter/starvation (from rev 19288, projects/haf/trunk/clutter0.8)

Modified: projects/haf/branches/clutter/starvation/clutter/x11/clutter-event-x11.c
===================================================================
--- projects/haf/trunk/clutter0.8/clutter/x11/clutter-event-x11.c	2009-09-03 10:03:44 UTC (rev 19288)
+++ projects/haf/branches/clutter/starvation/clutter/x11/clutter-event-x11.c	2009-09-03 16:11:24 UTC (rev 19289)
@@ -816,9 +816,16 @@
   Display           *xdisplay = backend_x11->xdpy;
   XEvent             xevent;
   ClutterMainContext  *clutter_context;
+  static GTimer *timer;
 
   clutter_context = clutter_context_get_default ();
 
+  /* Observe the elapsed time we spend on event processing not to starve
+   * g_timeout_add() callbacks to death. */
+  if (!timer)
+    timer = g_timer_new ();
+  g_timer_start (timer);
+
   while (!clutter_events_pending () && XPending (xdisplay))
     {
       XNextEvent (xdisplay, &xevent);
@@ -834,6 +841,10 @@
         {
           clutter_event_free (event);
         }
+
+      /* Take a break every 40 milisecs. */
+      if (g_timer_elapsed (timer, NULL) >= 0.04)
+        break;
     }
 }
 

More information about the maemo-commits mailing list