summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthreadpool_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Modernize the "thread" featureUlf Hermann2018-08-171-2/+1
| | | | | | | | | | Add it to configure.json and replace all occurrences of QT_NO_THREAD with QT_CONFIG(thread). Add conditions for other features that depend on thread support. Remove conditions where we can use the QMutex and QThreadStorage stubs. Change-Id: I284e5d794fda9a4c6f4a1ab29e55aa686272a0eb Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-161-1/+83
|\ | | | | | | Change-Id: I3cf73c53cf131d0babfb558c2507bed0e0fc5f08
| * Improve performance in QThreadPoolSvenn-Arne Dragly2017-10-041-1/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When many runnables are executed, this improves the performance by not resizing the queue for each runnable, which was the case in the previous version, because of many calls to QVector::takeFirst(). Also add a test that makes sure tryTake() is safe to call and does not leave the queue in a bad state that tries to use nullptr entries. Change-Id: I608134ecfa9cfc03db4878dcbd6f9c1107e13e90 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add QThreadPool::stackSizeMorten Johan Sørvig2017-08-021-0/+1
| | | | | | | | | | | | | | | | | | Allows setting the stack size for the thread pool worker threads. Implemented using QThread::stackSize. Task-number: QTBUG-2568 Change-Id: Ic7f3981289290685195bbaee977a23e0c3c49bf0 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Make QThreadPoolPrivate use NSDMIsMorten Johan Sørvig2017-08-021-5/+6
|/ | | | | | | | | | | (non static data member initializers) Also, taking the absolute value of the idealThreadCount() return value is no longer needed since the function now returns 1 for the "CPU detection failure" case. Change-Id: I2214fd15ed24413bba796ead38bbf1355dfd37d9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QThreadPool: supersede cancel() with tryTake()Marc Mutz2017-02-221-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | The cancel() function added in 5b11e43e for Qt 5.5 suffers from a number of problems: First, if runnable->autoDelete() is true, then the function suffers from the ABA problem (see documentation written for trytake()). Second, if runnable->autoDelete() is false, due to cancel() throwing away crucial information instead of returning it, the caller cannot know whether the runnable was canceled (and thus has to be deleted), wasn't found or is currently executing (and thus mustn't be deleted), or has finished executing (and can be used to extract the result). Deprecate this dangerous API and replace it with the much more useful Private::stealRunnable(), promoted to public API and renamed to tryTake() for consistency with the rest of Qt. Described the various caveats in the function's documentation. [ChangeLog][QtCore][QThreadPool] The cancel() function suffers from several subtle issues and has been replaced with a new tryTake() function. Change-Id: I93125935614087efa24b3e3969dd6718aeabaa4f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QThreadPool: replace a QSet with a QListMarc Mutz2017-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | QThreadPool maintains three containers of QThreadPoolThread*: - allThreads, a QSet - waitingThreads, a QQueue - expiredThreads, also a QQueue None of the operations on allThreads make use of QSets fast lookup. The only functions called on it are isEmpty(), count(), insert(), and swap(). Since therefore QSet adds nothing but overhead, causes indeterminism (e.g. when deleting threads in Private::reset()) and code bloat, use the same container for allThreads that underlies QQueue: QList. Port insert() to append(). Add an assert to verify that we're not running into an ABA problem here (but this should never fire, since we're never deleting threads except in Private::reset(), where we do remove them from allThreads), just in case. Saves ~0.5KiB in text size on optimized Linux AMD64 GCC 7.0 builds. Change-Id: I53a4d5ef2c204420f7c8852f1e72ab3d6ea43d08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QPair<QRunnable*, int> is too large for QList to be efficient-ish.Volker Krause2016-01-071-1/+1
| | | | | | | | | | Qt3D is making heavy use of this, causing the QList node allocations to be among the top 10 per frame allocation sources. Switching to QVector fixes that. Change-Id: I3b4df329710f82bf8d6797ea1f0c79b288a08063 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* QThreadPool::cancel() to remove individual jobs from the job queue.Nick Shaforostoff2014-12-241-1/+2
| | | | | | | | | [ChangeLog][QtCore][QThreadPool] Added QThreadPool::cancel() which allows removing from the job queue a job that hasn't been started yet. Change-Id: Ib8f1c1f32a34f5eec8338c641d820b928e470164 Reviewed-by: Nick Shaforostoff <shafff@ukr.net> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QThreadPool: fix race at time of thread expiry.David Faure2013-10-311-2/+1
| | | | | | | | | | | | | | | | | | | | The current synchronization mechanism was racy: decrementing waitingThreads and then hoping that the wakeOne will wake a thread before its expiry timeout happens. In other words, on timeout, a just-assigned task would never run. And then no other task would run, if maxThreadCount is reached. Fixed by using a queue of waiting threads (rather than just a count), and by moving the wait condition into the thread itself, so we know precisely which one we're waking up, and we can remove it from the set of waiting threads before waking it up, and therefore it can determine on wakeup whether it has work to do (caller removed it from the queue) or it expired (it's still in the queue). This is reliable, whereas the return value from QWaitCondition::wait isn't reliable, when the main thread has already decided that this thread has work to do. Task-number: QTBUG-3786 Change-Id: I1eac5d6c309daed7f483ac7a8074297bfda6ee32 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThreadPool - Add method clear() to remove queued QRunnable.Corentin Jabot2013-08-161-0/+1
| | | | | | | | | | | | | | QThreadPool::clear() method removes all queued QRunnable. When a large number of long-running tasks are queud in a QThreadPool its destruction, which calls waitForDone(), can be quite long. QThreadPool:clear() removes (and deletes when appropriate) all QRunnable that have yet to be started from the queue enabling a faster interruption. Change-Id: Ie5d6028ad3cfe7e439d1db068c8d0936ff818db9 Reviewed-by: David Faure <david.faure@kdab.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QThreadPool: unify waitForDone() overloadsKonstantin Ritt2012-04-171-1/+1
| | | | | Change-Id: I1515a65fab37588372794422a43ed09ac076e108 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Remove unused QThreadPoolPrivate::startFrontRunnable().Robin Burchell2012-03-061-1/+0
| | | | | Change-Id: Ie079aea3412a53cf9dccaa770fa64ff5b6b7b3b1 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Move QtConcurrent into its own moduleLars Knoll2012-02-051-0/+107
Task-number: QTBUG-20892 Change-Id: I614500aafb6428915509983608bbb0ade4e4f016 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>