diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/thread/qthread.cpp | 23 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 18 |
2 files changed, 24 insertions, 17 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 208420b8fe..08a010124a 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -19,6 +19,29 @@ QT_BEGIN_NAMESPACE /* + QPostEventList +*/ + +void QPostEventList::addEvent(const QPostEvent &ev) +{ + int priority = ev.priority; + if (isEmpty() || + constLast().priority >= priority || + insertionOffset >= size()) { + // 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 = std::upper_bound(begin() + insertionOffset, end(), ev); + insert(at, ev); + } +} + + +/* QThreadData */ diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 7909f00e37..63c518fb57 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -73,23 +73,7 @@ public: inline QPostEventList() : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0) { } - void addEvent(const QPostEvent &ev) - { - int priority = ev.priority; - if (isEmpty() || - constLast().priority >= priority || - insertionOffset >= size()) { - // 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 = std::upper_bound(begin() + insertionOffset, end(), ev); - insert(at, ev); - } - } + void addEvent(const QPostEvent &ev); private: //hides because they do not keep that list sorted. addEvent must be used |