ecore: Sleep at least until the next timeout
authormike_m <mike_m@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 5 Jul 2011 02:32:07 +0000 (02:32 +0000)
committermike_m <mike_m@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 5 Jul 2011 02:32:07 +0000 (02:32 +0000)
The g_main_loop was spinning waiting for timers that were
almost ready.  The spinning was due to waking up from
the g_main_loop too early, and then having nothing to do.

To solve this, round the timeout up to the nearest millisecond,
so that when the main loop wakes, the timer will definitely be
ready.

Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@61028 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/ecore_main.c

index e6db6a5..f376817 100644 (file)
@@ -463,7 +463,7 @@ _ecore_main_gsource_prepare(GSource *source __UNUSED__, gint *next_time)
              if (_ecore_timers_exists())
                {
                   double t = _ecore_timer_next_get();
-                  *next_time = (t * 1000.0);
+                  *next_time = ceil(t * 1000.0);
                }
              else
                *next_time = -1;