diff options
author | Rafael Roquetto <rafael.roquetto.qnx@kdab.com> | 2012-07-04 15:23:03 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-05 20:51:25 (GMT) |
commit | 696018e016ae49c9ee6df2023fee37c0bd57ec8c (patch) | |
tree | f802ee0e08e89986996cb9f3bba91b0e0f4acedc /src/corelib/kernel | |
parent | 02d31133a93bc157362251241788196da45aacce (diff) | |
download | Qt-696018e016ae49c9ee6df2023fee37c0bd57ec8c.zip Qt-696018e016ae49c9ee6df2023fee37c0bd57ec8c.tar.gz Qt-696018e016ae49c9ee6df2023fee37c0bd57ec8c.tar.bz2 |
[Blackberry] Fix event loop throughput issue
Currently, only one bps event can be handled per event loop iteration,
bringing about a huge performance penalty. This patch fixes this issue by
bulk processing events whenever they are available.
cherry-picked from qt5/qtbase 40bfbf3a5b765d939a7eea999c49da5b16456ad1
Change-Id: I52cc82d93754c2f6acf66f5b0445e34a68d233bf
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_blackberry.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 1157098..9a9cb8a 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -42,6 +42,7 @@ #include "qeventdispatcher_blackberry_p.h" #include "qsocketnotifier.h" #include "qdebug.h" +#include "qelapsedtimer.h" #include <bps/bps.h> #include <bps/event.h> @@ -265,15 +266,31 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef if (timeout) timeout_ms = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); - // wait for event or file to be ready - bps_event_t *event = NULL; - result = bps_get_event(&event, timeout_ms); - if (result != BPS_SUCCESS) - qWarning("QEventDispatcherBlackberry::select: bps_get_event() failed"); + QElapsedTimer timer; + timer.start(); + + do { + // wait for event or file to be ready + bps_event_t *event = NULL; + + // \TODO Remove this when bps is fixed + // BPS has problems respecting timeouts. + // Replace the bps_get_event statement + // with the following commented version + // once bps is fixed. + // result = bps_get_event(&event, timeout_ms); + result = bps_get_event(&event, 0); + + if (result != BPS_SUCCESS) + qWarning("QEventDispatcherBlackberry::select: bps_get_event() failed"); + + if (!event) + break; - // pass all received events through filter - except IO ready events - if (event && bps_event_get_domain(event) != bpsIOReadyDomain) - filterEvent((void*)event); + // pass all received events through filter - except IO ready events + if (event && bps_event_get_domain(event) != bpsIOReadyDomain) + filterEvent((void*)event); + } while (timer.elapsed() < timeout_ms); // \TODO Remove this when bps is fixed (see comment above) result = bps_remove_fd(d->thread_pipe[0]); |