summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread
Commit message (Collapse)AuthorAgeFilesLines
* Fix compilation for WinRTMaurice Kalinowski2015-12-142-2/+4
| | | | | | | | TEST_HELPER_INSTALLS cannot be used on platforms with no QProcess support. Change-Id: I2a6a283d94ca4487fc628449c53fc37140dd291d Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
* tst_QThreadPool::tryStartCount(): Wait until tasks have finished.Friedemann Kleint2015-11-272-4/+1
| | | | | | | | | | | | Replace hardcoded interval by QTRY_COMPARE() ensuring that all tasks have finished, since otherwise QThreadPool::tryStart() fails in the next run. Remove blacklisting for MSVC2012 since it is not compiler-specific. Task-number: QTBUG-49654 Change-Id: If49b6eb9ef4da4ba2911839166c397d84c175e00 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* tst_QWaitCondition::wakeOne(): Increase wait interval.Friedemann Kleint2015-11-261-4/+7
| | | | | | | | | Introduce constants and make the interval for the 2nd thread a bit longer. Task-number: QTBUG-49653 Change-Id: I92ac0494ec6c9af5bde858007d08e26210215434 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* tst_QWaitCondition: Prevent test functions from interfering with each other.Friedemann Kleint2015-11-261-35/+106
| | | | | | | | | | | | | | | | | | Introduce a base class for the threads that ensures termination in the destructor to ensure all QThreads instantiated on the stack are terminated. This should reduce crashes since the test thread classes have pointers to stack variables of the test slots. Set object names on the threads for better diagnostics. Decouple wakeOne()/wakeAll() that impact each other via the static count variables of the thread class by introducing a base class WakeThreadBase keeping a pointer to an QAtomicInt count variable on the stack instead (similar to the existing pointers to the mutexes, etc). Task-number: QTBUG-49653 Change-Id: I73537386bf36019efa81e8e24ba9af92506f7794 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
* Fix pauseEvents() test to test what should be true, not what is.Edward Welbourne2015-11-021-10/+8
| | | | | | | | | | | | | | | | If the future is finished when a watcher starts watching it, it is perfectly reasonable for the watcher to get the finished message promptly. If you pause the watcher before any message loops get to run, the message presently won't get through until the watcher is resumed, but there is no reason to guarantee that; indeed, one could consider it somewhat perverse behavior. So move the reportFinished() calls to after the pause()s. Also eliminate a used-once local variable and use QTRY_VERIFY() in one place where qWait() was used before. Change-Id: I4bc6091fd7437a4d341be511b7a140f3d72d850e Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Attach all signal spies before setting the watcher's future.Edward Welbourne2015-11-021-12/+11
| | | | | | | | Attaching spies afterwards was provoking a warning during tests: QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race Change-Id: I6ee8c3613cecebd1c69b0337139d8a19a33f4a11 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Make the C++11 atomic support the default, if availableThiago Macieira2015-10-1618-19/+19
| | | | | Change-Id: Ib056b47dde3341ef9a52ffff13ef1647ccd607b1 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Initialize QFutureWatcherBasePrivate::finished and testEdward Welbourne2015-09-301-0/+13
| | | | | | | | | | | | | | It's accessed by QFutureWatcherBase::isFinished(), potentially before anything has set it. It gets to be initially true until setFuture() has given it us unfinished future and set it false. Add a regression test for matching state in future and watcher. Task-number: QTBUG-12358 Change-Id: Iae7bdaa434ab80f518afe4d7d55df99c391991a4 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Fix tst_qthreadstorageFrederik Gladhorn2015-09-241-1/+1
| | | | | | | | This test when running on Windows has a race condition since in qthread_win.cpp the finished signal is emitted before everything is cleaned up. Change-Id: I3c03d9a245e297e8f79b2be2c34398bf7bac9bae Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Tests: Replace Q[TRY]_VERIFY(v == true|false) by QVERIFY(v)|QVERIFY(!v).Friedemann Kleint2015-07-272-21/+21
| | | | | | | | Preparing the replacement of Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) for non-boolean types. Change-Id: Iab6ec2f0a89a3adc79e18304573994965013dab5 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
* Tests: Do not rely on qCompare(bool, int,...).Friedemann Kleint2015-07-181-29/+29
| | | | | | | | | The overload was added for NokiaX86 and RVCT and is bound for removal. Task-number: QTBUG-47260 Change-Id: Ic67cee8769847956e16cd0470ebcd663a9e98a40 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-07-011-41/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/global/qglobal.h src/corelib/global/qsysinfo.h src/corelib/global/qsystemdetection.h src/corelib/kernel/qobjectdefs.h src/plugins/plugins.pro tests/auto/widgets/itemviews/qlistview/qlistview.pro Change-Id: Ib55aa79d707c4c1453fb9d697f6cf92211ed665c
| * Use qthread_win.cpp for WinRT as wellOliver Wolff2015-06-231-41/+5
| | | | | | | | | | | | | | | | | | | | Since of Windows (Phone) 8.1 most of the desktop's thread functionality is also available, so we might be able to share the code and get rid of the extra implementation for WinRT. Task-number: QTBUG-43837 Change-Id: I0ce907cd94899834527f88c70e1e395bafdb14b3 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
* | Blacklist tryAcquireWithTimeoutSimon Hausmann2015-06-201-1/+1
| | | | | | | | | | | | | | All variants of the tests are timing out randomly on all platforms :( Change-Id: I9244602a8d06fd07d3cc99b2fb8fdf6e07e92cf2 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Blacklist and skip various tests that are flakeySimon Hausmann2015-06-143-0/+8
| | | | | | | | | | | | | | | | | | | | They didn't show up in the "old" CI runs because they usually pass the second time they are executed - which the testrunner does. The new CI doesn't do that anymore, instead we now mark those tests explicitly and will track their record of passing and failing in the new metrics database. Change-Id: Id34dd6f792f38995b07b6fec88f833df64de2f8b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Blacklist tst_QThreadPool::expiryTimeoutRace() on OS XSimon Hausmann2015-06-121-0/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes it works and sometimes it hangs. This is the back-trace when it hangs: FAIL! : tst_QThreadPool::expiryTimeoutRace() 'task.semaphore.tryAcquire(numTasks, 10000)' returned FALSE. () Loc: [tst_qthreadpool.cpp(380)] ========= Received signal, dumping stack ============== (lldb) process attach --pid 31360 Process 31360 stopped Executable module set to "/Users/qt/work/qt/qtbase/tests/auto/corelib/thread/qthreadpool/./tst_qthreadpool.app/Contents/MacOS/tst_qthreadpool". Architecture set to: x86_64-apple-macosx. (lldb) bt all * thread #1: tid = 0x11f82a, 0x00007fff87451716 libsystem_kernel.dylib`__psynch_cvwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP * frame #0: 0x00007fff87451716 libsystem_kernel.dylib`__psynch_cvwait + 10 frame #1: 0x00007fff8102dc3b libsystem_pthread.dylib`_pthread_cond_wait + 727 frame #2: 0x000000010b160dab QtCore`QWaitConditionPrivate::wait(unsigned long) + 75 frame #3: 0x000000010b160c62 QtCore`QWaitCondition::wait(QMutex*, unsigned long) + 162 frame #4: 0x000000010b15d66a QtCore`QThreadPool::~QThreadPool() + 106 frame #5: 0x000000010b0c6bec tst_qthreadpool`tst_QThreadPool::expiryTimeoutRace() + 380 frame #6: 0x000000010b0ccabb tst_qthreadpool`tst_QThreadPool::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 139 frame #7: 0x000000010b3138e2 QtCore`QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const + 1026 frame #8: 0x000000010b312f0a QtCore`QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) + 2122 frame #9: 0x000000010b0ec18f QtTest`QTest::qInvokeTestMethod(char const*, char const*, QTest::WatchDog*) + 1535 frame #10: 0x000000010b0e7847 QtTest`QTest::qExec(QObject*, int, char**) + 1447 frame #11: 0x000000010b0cc954 tst_qthreadpool`main + 132 frame #12: 0x000000010b0c4e74 tst_qthreadpool`start + 52 thread #2: tid = 0x11f82c, 0x00007fff87452662 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager' frame #0: 0x00007fff87452662 libsystem_kernel.dylib`kevent64 + 10 frame #1: 0x00007fff88af1421 libdispatch.dylib`_dispatch_mgr_invoke + 239 frame #2: 0x00007fff88af1136 libdispatch.dylib`_dispatch_mgr_thread + 52 thread #3: tid = 0x11f82e, 0x00007fff87451e3a libsystem_kernel.dylib`__wait4_nocancel + 10, name = 'QThread' frame #0: 0x00007fff87451e3a libsystem_kernel.dylib`__wait4_nocancel + 10 frame #1: 0x00007fff81911090 libsystem_c.dylib`system + 425 frame #2: 0x000000010b0e6fa6 QtTest`stackTrace() + 150 frame #3: 0x000000010b0efd1d QtTest`QTest::WatchDog::run() + 77 frame #4: 0x000000010b15f723 QtCore`QThreadPrivate::start(void*) + 339 frame #5: 0x00007fff8102b899 libsystem_pthread.dylib`_pthread_body + 138 frame #6: 0x00007fff8102b72a libsystem_pthread.dylib`_pthread_start + 137 frame #7: 0x00007fff8102ffc9 libsystem_pthread.dylib`thread_start + 13 (lldb) quit ========= End of stack trace ============== QFATAL : tst_QThreadPool::expiryTimeoutRace() Test function timed out FAIL! : tst_QThreadPool::expiryTimeoutRace() Received a fatal error. Loc: [Unknown file(0)] Change-Id: I12a61496e101c1bc04bb7f1141c4f6318e8238e4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Do not search test binary if QProcess is not supported.Pasi Petäjäjärvi2015-03-231-0/+2
| | | | | | | | Without QProcess support we do not run test which initTestCase is trying to find. Change-Id: Icecaad90f61a019489e372517a6d62372155bd46 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Skip instead of entirely excluding tests with disabled featuresMarko Kangas2015-03-161-3/+5
| | | | | | | | | | | | Properly QSKIP tests that use disabled QProcess and symlink features instead of excluding them silently by #ifdef. Other reason is that moc doesn't respect QT_NO_* defines in class definition which causes build issues on some platforms. Change-Id: I041020f7452f7d36c7ec8a5866a4ba5eb23d1f94 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Add missing fetchAndXxx methods to atomic classes based on std::atomicThiago Macieira2015-03-0551-19/+111
| | | | | | | | And add tests for the GCC intrinsics and for std::atomic. Task-number: QTBUG-43794 Change-Id: Ic5d393bfd36e48a193fcffff13b9b2dbaee80469 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Update copyright headersJani Heikkinen2015-02-1121-146/+146
| | | | | | | | | | | | | | | | | | 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-0/+51
| | | | | | | | | [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>
* Use the new warning enabling/disabling macros in qtbaseThiago Macieira2014-12-031-7/+3
| | | | | | Change-Id: I91ff06644e8047c2ca483f9768b46c1372eb6171 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* tst_QThreadPool: fix memleakMarc Mutz2014-10-191-6/+6
| | | | | | | Benign, but easy to avoid by using the same pattern as in clear(). Change-Id: Ie382313343385f0709519b232a7d58dd8181b8de Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update license headers and add new license filesMatti Paaso2014-09-2421-398/+230
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QFutureInterface: allow to work with a QThreadPool != globalInstance()Marc Mutz2014-08-051-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Background: It is often necessary/advisable to schedule tasks on thread pools != globalInstance(). As Herb Sutter writes in http://www.drdobbs.com/parallel/use-thread-pools-correctly-keep-tasks-sh/216500409 and the Qt Training Material stresses, tasks you schedule on a (global) thread pool should be non-blocking, which currently rules out using any of the QtConcurrent functions for, say, file I/O. Nonetheless it's often convenient to have thread pools also for file I/O, as the thumbnail viewer exercise in the Qt Training Material shows. In this case, you'd use a dedicated thead pool, leaving the global thread pool for CPU-bound tasks. Yet, none of the QtConcurrent functions allow to pick the QThreadPool instance on which to schedule the work created with them. This patch prepares for them to do so. This is the first part of the forward-port of https://qt.gitorious.org/qt/qt/merge_requests/1281. Implement by using a new QThreadPool* member that defaults to nullptr, and adding setThreadPool to set this member, then using it in lieu of QThreadPool::globalInstance() everywhere. I chose to leave m_pool == nullptr to mean globalInstance() to avoid creating the global instance whenever a QFuture is created, even if the future represents the result of a calculation not run on the global thread pool. [ChangeLog][QtCore][QFuture] Can now be used with any QThreadPool, not just globalInstance(). Task-number: QTBUG-17220 Change-Id: I4e1dc18d55cf60141b2fa3d14e2d44a3e9e74858 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-07-031-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/accessible/qaccessiblecache_mac.mm src/gui/accessible/qaccessiblecache_p.h src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h src/plugins/platforms/cocoa/qcocoawindow.h src/plugins/platforms/cocoa/qcocoawindow.mm src/widgets/kernel/qwidget_qpa.cpp Manually moved change in qwidget_qpa.cpp to qwidget.cpp (cd07830e3b27da7e96a0a83f91ba08c168b45e62) Change-Id: Ia51f471f9b53de2f3b07d77ea89db9303ac8961d
| * Skip unstable autotests in QtBase.Morten Johan Sørvig2014-07-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The combination of these unstable tests makes it very hard to get changes through the CI system due to the unrelated test failures. Skip the following test functions: tst_QIODevice::unget QTBUG-39983 (Mac) tst_QThreadPool:expiryTimeoutRace QTBUG-3786 (Windows) tst_QLocalSocket::processConnection QTBUG-39986 (Mac) tst_QTcpServer::adressReusable QTBUG-39985 (Linux) Change-Id: I96559bea0d437fd25966b6ccac1ece1490e06241 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* | winrt: Use native threadingAndrew Knight2014-06-251-24/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using std::thread, use the WinRT ThreadPool to manage threads. This allows for setting the scheduling priority, and provides a path to enable XAML integration (which requires Qt run on a background thread). QThread::terminate() is still unsupported, and only the winmain thread can be adopted due to the behavior of the thread pool when creating tasks from the GUI thread. The associated tests are now skipped, and all other QThread tests pass. Task-number: QTBUG-31397 Change-Id: Ib512a328412e1dffecdc836bc39de3ccd37afa13 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | Updated corelib's unit tests to use QSignalSpy's functor constructorKeith Gardner2014-05-081-19/+19
|/ | | | | | | | | The intent is to provide compile time validation of signals and to help detect signal overloading in the future. Change-Id: I9d5d46ed4b70c5d0cd407deb5928b1e76d37e007 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Fix tst_qthreadpool under high load.David Faure2014-03-141-0/+1
| | | | | | | | | | The tasks might not have run yet at the time of the QCOMPARE, so we need to acquire on the semaphore in order to ensure that this is the case, just like in the previous testcase. Change-Id: I1da72bb07c2f53760b3bf912fc26aaf10ed18d48 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Remove use of templates in tst_qatomicinteger.Friedemann Kleint2014-03-041-2/+2
| | | | | | | | | | | | | | | | | | | | MSVC 2008 is confused by TypeInStruct being a template, resulting in \tst_qatomicinteger.cpp(189) : error C2027: use of undefined type 'QStaticAssertFailure<Test>' with [ Test=false ] for int (and thus for all unsupported types). This appears to be a real Heisenbug-nature compiler bug as it can also be fixed by adding qDebug() << Q_ALIGNOF(TypeInStruct<T>) before the static assert. Task-number: QTBUG-37195 Change-Id: Ib2b60f3c1ffeb0b8bdeb1fb0c659655ce4ab10d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a testAndSet overload to the atomics that returns the current valueThiago Macieira2014-02-163-1/+525
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is extremely useful, since the most common action after a failed compare-and-swap is to loop around, trying again with the current value as found in memory. Code currently written as: do { Type value = atomic.load(); ... } while (!atomic.testAndSetRelaxed(value, desired)); Becomes: Type value = atomic.load(); do { ... } while (!atomic.testAndSetRelaxed(value, desired, value)); In most CPU architectures, the value that was found in memory is known to the compare-and-swap code, so this is more efficient than the previous code. In architectures where the value is not known, the new code is no worse than before. The implementation sometimes modified an existing function, sometimes it added a new one, depending on whether more registers were needed in the assembly (like ARMv6-7), the code became more complex (ARMv5), the optimizer failed (C++11), or it was just plain equivalent (MIPS). Change-Id: I7d6d200ea9746ec8978a0c1e1969dbc3580b9285 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace the type-based QAtomicIntegerTraits with a size-based oneThiago Macieira2014-01-3021-6/+513
| | | | | | | | This simplifies the code a lot and avoids silly mistakes where a specific integer type is missing (such as char16_t). Change-Id: Id91dfd1919e783e0a9af7bfa093ca560a01b22d1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* tst_qthreadpool: fix memory leakDavid Faure2013-11-281-1/+2
| | | | | | Task-number: QTBUG-22673 Change-Id: I2e554a2ad0119b5f9ce2d36e4720538af5ef6b82 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-11-261-5/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the conflicts in msvc_nmake.cpp the ifdefs are extended since we need to support windows phone in the target branch while it is not there in the current stable branch (as of Qt 5.2). Conflicts: configure qmake/generators/win32/msvc_nmake.cpp src/3rdparty/angle/src/libEGL/Surface.cpp src/angle/src/common/common.pri src/corelib/global/qglobal.h src/corelib/io/qstandardpaths.cpp src/plugins/platforms/qnx/qqnxintegration.cpp src/plugins/platforms/qnx/qqnxscreeneventhandler.h src/plugins/platforms/xcb/qglxintegration.h src/widgets/kernel/win.pri tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp tools/configure/configureapp.cpp Change-Id: I00b579eefebaf61d26ab9b00046d2b5bd5958812
| * Fix test compilation on WinRTAndrew Knight2013-11-261-3/+7
| | | | | | | | | | | | | | | | Tweak a handful of tests which didn't compile on this platform. Change-Id: I208d9eb289dfb226746c6d0163c3ea752485033b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* | QThreadPool: fix race at time of thread expiry.David Faure2013-10-311-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Winrt: Skip qthread autotests, which are not supported (yet)Oliver Wolff2013-10-021-0/+12
| | | | | | | | | | | | Change-Id: Ib1047731667ba8a7b9db2f62924eb42a6b85b4fd Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
* | Winrt: tst_qthread: Added QEXPECT_FAIL where neededOliver Wolff2013-10-021-0/+12
| | | | | | | | | | | | Change-Id: I88d98421978e0f5c55af8647f3f74c265b45bd37 Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
* | WinRT: Fix various test compilationsAndrew Knight2013-10-022-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | - Remove irrelevant test subdirs via .pro files - Follow WinCE codepaths where applicable - Replace unsupported Win32 APIs with WinRT equivalents This does not aim to fix any failures in the tests themselves; it only makes them compile. Change-Id: Ia82bc0cc402891f8f6238d4c261ee9152b51be80 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | threading support for winrtKamil Trzcinski2013-09-261-0/+12
|/ | | | | | Change-Id: Ife296e15ddf727c3f53ab3d3d84634b5c7bbf85c Done-with: Maurice Kalinowski Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* tst_QReadWriteLock: replace a volatile bool with an atomic intMarc Mutz2013-09-231-6/+6
| | | | | | | | Fixes the obvious race between the test of 'release' in the thread and the setting of 'release' in the test function. Change-Id: I92df52d7b18e8154f17229a3dbd4a0e58f4a3b5b Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* tst_QMutex: fix a raceMarc Mutz2013-09-231-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code uses a QSignalSpy to check whether the thread started, but the signal emission (and subsequent appending to the spy) and the check for spy.count() before the final thr.wait() are not synchronized: The signal emission happens-after the thr.start() and -before the final thr.wait(). Likewise, the spy.count() happens-after thr.start() and -before thr.wait(), but neither one happens-before the other. Thus, there is a data race. The wait(200) between thr.start() and mutex.unlock() doesn't help, either, because we check only that it doesn't return true, iow, we check that it timed out. But it will happily do that if the thread has not yet started executing, so there's no happens-before relation to be had via that avenue, either. I first fixed by moving the spy.count() check to after thr.wait(). In that case: signal emission happens-before thread finishing happens-before thr.wait() returning happens-before spy.count() so no race. Arguably, that makes the check rather useless, so I decided to remove it completely. Change-Id: I6bb47c4114961ee6e9251cfebeb4b7794ba674a9 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Add an advisory interruption mechanism to QThread.Corentin Jabot2013-09-051-0/+40
| | | | | | | | | | | | | | To ease interruption of long running tasks, a new method QThread::setInterruptionRequested() can be called. The task can check QThread::isInterruptionRequested() and act upon it by stopping itself. These methods are designed to replace the use of a global variable and other hacky ways to stop a task running in another thread. Change-Id: I17622dd60d2262078210e7e4294ad6c53a6dc179 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qthreadpool: fix flaky test I introduced in last commitDavid Faure2013-08-291-0/+4
| | | | | | | | | (dacf9961da86) In order to see 2 active threads, we must check activeThreadCount() before the runnable finishes. Change-Id: I1a48b41e0c1fd81a65d915b9bd1e741ff267ed2b Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QThreadPool: fix counting of waiting threadsDavid Faure2013-08-241-0/+56
| | | | | | | | | | | | | | | | | | QTBUG-21051 has a testcase where activeThreadCount() could actually end up at -1 (converted to an autotest in this commit). The reason was: start() calls tryStart() which returns false due to too many active threads (reserveThread() causes this), so it calls enqueueTask() - which actually wakes up the waiting thread, but it didn't decrement the number of waiting threads. Note that tryStart() is "if I can grab a waiting thread, enqueue task and wake it" while start(), in case tryStart() fails, wants to "enqueue, and then if I can grab a waiting thread, wake it". This is why enqueue shouldn't wake; waking must happen only if we can grab a thread (d->waitingThreads > 0). Task-number: QTBUG-21051 Change-Id: I3d98337103031c9bdf0bf365295f245be0c66aa7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThreadPool - Add method clear() to remove queued QRunnable.Corentin Jabot2013-08-161-0/+29
| | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-05-231-0/+53
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qdatastream.cpp src/corelib/io/qdatastream.h src/corelib/json/qjsonwriter.cpp src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbkeyboard.cpp Change-Id: I46fef1455f5a9f2ce1ec394a3c65881093c51b62
| * QThreadPool: Fix regression from Qt 4 in dealing with priority startsThiago Macieira2013-05-201-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | The optimisation done in cbaf52b09971edf6f3e1458f7dd677b80a1568ed for Qt 5.0 got the order wrong of the comparison. The queue must be sorted in decreasing priority order. But since higher numbers mean higher priority, that means the queue must be sorted in decreasing priority number order. Task-number: QTBUG-29163 Change-Id: Iaf3424b9bb445bf5c71518927f37253cead454f3 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* | Fix some data races in tst_qthreadpool.David Faure2013-05-191-16/+16
|/ | | | | | | Detected by helgrind. Change-Id: I5f73a62610b4bdc7f26629f3dcf7b11467897a5c Reviewed-by: Olivier Goffart <ogoffart@woboq.com>