summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-06-27 18:53:44 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-06-27 18:53:44 (GMT)
commit3c67a14ad0db0e83e70b2432394f168ce279518b (patch)
tree77ba4c394f39886b21da6645723ebde9253788f2 /src/corelib/thread
parentb39dc4a9029040f43f1ca3ace6bf7e77740a3f39 (diff)
parent007f01a7e801d5409708e4b8de8b3ead1481cf7d (diff)
downloadQt-3c67a14ad0db0e83e70b2432394f168ce279518b.zip
Qt-3c67a14ad0db0e83e70b2432394f168ce279518b.tar.gz
Qt-3c67a14ad0db0e83e70b2432394f168ce279518b.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging: Make it compile with openssl 1.0.0d, gcc 4.6 QStringBuilder: do not crash with null char* Fix event delevery order QSocketNotifier autotest - fix compile with MSVC
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread_p.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 13df3e6..461d93d 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -93,6 +93,8 @@ inline bool operator<(const QPostEvent &pe, int priority)
return priority < pe.priority;
}
+// This class holds the list of posted events.
+// The list has to be kept sorted by priority
class QPostEventList : public QList<QPostEvent>
{
public:
@@ -109,6 +111,25 @@ public:
inline QPostEventList()
: QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0)
{ }
+
+ void addEvent(const QPostEvent &ev) {
+ int priority = ev.priority;
+ if (isEmpty() || last().priority >= priority) {
+ // optimization: we can simply append if the last event in
+ // the queue has higher or equal priority
+ append(ev);
+ } else {
+ // insert event in descending priority order, using upper
+ // bound for a given priority (to ensure proper ordering
+ // of events with the same priority)
+ QPostEventList::iterator at = qUpperBound(begin() + insertionOffset, end(), priority);
+ insert(at, ev);
+ }
+ }
+private:
+ //hides because they do not keep that list sorted. addEvent must be used
+ using QList<QPostEvent>::append;
+ using QList<QPostEvent>::insert;
};
#ifndef QT_NO_THREAD