From c5f16efa34157cef1af3559f6bbd048ed609f8ad Mon Sep 17 00:00:00 2001 From: Daniel Thor Kristjansson Date: Wed, 20 Jun 2012 15:17:15 -0400 Subject: Fixes high CPU usage on timer expiration when using glib event loop. GTimerSource has 1ms accuracy, QTimerInfoList::timerWait() has 1us accuracy. So when there is less than 1 ms left on the timer we enter a tight loop checking for timer expiration since we don't round up the timerWait() timer to the nearest millisecond. Task-number: QTBUG-7618 Change-Id: I684c9236324f598bc69c6810be270aa47c791f91 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qeventdispatcher_glib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index 4429679e72..3f75c4ec72 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -133,7 +133,7 @@ static gboolean timerSourcePrepareHelper(GTimerSource *src, gint *timeout) { timeval tv = { 0l, 0l }; if (!(src->processEventsFlags & QEventLoop::X11ExcludeTimers) && src->timerList.timerWait(tv)) - *timeout = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); + *timeout = (tv.tv_sec * 1000) + ((tv.tv_usec + 999) / 1000); else *timeout = -1; -- cgit v1.2.3