summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
Commit message (Collapse)AuthorAgeFilesLines
* Introduce swap functions for QPromise/QFutureInterfaceAndrei Golubev2020-08-034-15/+35
| | | | | | | | | | Made QPromise::swap public, added free standing swap() for QFutureInterface and QPromise. Updated QPromise special member functions. Extended tests Task-number: QTBUG-84977 Change-Id: I5daf6876df306d082441dbcdf5ae4dee3bfc0ead Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-311-4/+4
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QThread::create: remove the pre-C++17 codepathsGiuseppe D'Angelo2020-07-072-99/+3
| | | | | | | | | | | As we require C++17 now. The configure-time test checking for future/async is left in for the moment being. Change-Id: Ifde39d420673f70a2277f5a645bfaad30935a381 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-072-2/+2
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix workaround in pthread destructorMike Achtelik2020-07-041-19/+6
| | | | | | | | | | | | | | | | | Amends dcdfb6908db0f83cbc4e550859f56ee58a6b3420 which failed to take the workaround in destroy_current_thread_data into account. Since pthread_getspecific was completely replaced with the thread_local variable currentThreadData, the workaround has no effect anymore. Therefore we need to replace it with a workaround that makes sure currentThreadData is set inside of the destructor function. This prevents a leak, where QThreadPrivate::finish() tries to access the thread data, but since it already is null, recreates it without ever deleting it. Pick-to: 5.15 Change-Id: I3811d262a411a6bde9d6eb90f8d17e0bbc5de657 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "Remove pthread storage for thread local data"Alexandru Croitor2020-07-021-21/+59
| | | | | | | | | | | | The change introduced crashes in some tests that only surfaced in certain CMake configurations. This reverts commit 76c3eee4020cae681857ee17406c655f61f9082c. Pick-to: 5.15 Task-number: QTBUG-85357 Change-Id: Ief93aa41e2d487d73b879133e7df0fd5ce0451bd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-292-7/+7
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Remove pthread storage for thread local dataMike Achtelik2020-06-281-59/+21
| | | | | | | | | | | | | | | | | The thread specific QThreadData is currently referenced as a thread_local variable and using a thread specific value via pthread_setspecific. Having both is not necessary, as the pthread value is never directly accessed and only used in the pthread destructor. Using a holder, we can achieve the same and get rid of the pthread handling altogether. This also fixes a bug, where the thread_local currentThreadData is already null, when entering the pthread destructor. In this case it would lead to a new QThreadData being created, when finishing an adopted thread. Pick-to: 5.15 Change-Id: Ib23b840f804637e6b7cebd89016672a34a575380 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread: Fix unnecessary stricter accesses to QThreadData::threadThiago Macieira2020-06-251-6/+6
| | | | | | | | | Commit ec6556a2b99df373eb43ca009340a7f0f19bacbd changed the member from a plain pointer to a QAtomicPointer. Not all accesses were caught. Pick-to: 5.15 Change-Id: I3d4f433ff6e94fd390a9fffd161b4ff25508c48d Reviewed-by: David Faure <david.faure@kdab.com>
* Use QList instead of QVector in corelibJarek Kobus2020-06-254-24/+20
| | | | | | | | | | Applied to headers only. Source file to be changed separately. Omitted statemachine for now to avoid conflicts. Omitted qmetatype.h for now - to be handled later. Task-number: QTBUG-84469 Change-Id: I317376037a62467c313467d92955ad0b7473aa97 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix living QObject after shutdown of QCoreApplicationAndré Klitzing2020-06-231-3/+8
| | | | | | | | | | | | QThreadPool is a QObject and must be deleted if the QCoreApplication is being destroyed to release the underlying ThreadData. A Q_GLOBAL_STATIC won't release any memory is not able to manually release it. Pick-to: 5.15 Task-number: QTBUG-84234 Change-Id: Ia82bcff2b564b753ed687f025ff86fa1bed1e64c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-196-20/+20
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Document QPromise APIAndrei Golubev2020-06-182-0/+236
| | | | | | | | | Documented QPromise. Added snippets under auto tests to ensure they are compiled and run in CI. Task-number: QTBUG-81586 Change-Id: I20084e38f9d2f6fc8540f95ee03ec3d2827177e8 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Add QPromise implementationAndrei Golubev2020-06-095-1/+179
| | | | | | | | | | | | | | | | | | | | | | QPromise and QFuture created from it share the same internal state (namely, QFutureInterface object). QPromise provides high-level management of the shared resource, ensuring thread-safe behavior on construction and destruction (also taking into account QFuture::waitForFinished() semantics). QFuture acts as a primary controller of QPromise via action initiating methods such as suspend() or cancel(). QPromise is equipped with methods to check the status, but the actual handling of QFuture action "requests" is user-defined. [ChangeLog][QtCore][QPromise] Added QPromise class to accompany QFuture. It allows one to communicate computation results and progress to the QFuture via a shared state. Task-number: QTBUG-81586 Change-Id: Ibab9681d35fe63754bf394ad0e7923e2683e2457 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove winrtOliver Wolff2020-06-065-137/+9
| | | | | | | | | Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove QThreadPool::cancel()Allan Sandfeld Jensen2020-06-053-24/+0
| | | | | | | Deprecated in 5.9 Change-Id: Ib6e2a5da1e7ee2664fb6fa496bdc880fab870901 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Deprecate the pause-related APIs of QFuture* classesSona Kurazyan2020-06-047-88/+365
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Deprecated the pause-related APIs of QFuture* classes and added alternatives having "suspend" in the name instead. With 2f15927f01ceef0aca490746302a5ea57ea9441c new isSuspended()/suspended() APIs have been added to QFuture* classes for checking if pause/suspension is still in progress or it already took effect. To keep the naming more consistent, renamed: - setPaused() -> setSuspended() - pause() -> suspend() - togglePaused() -> toggleSuspended() - QFutureWatcher::paused() -> QFutureWatcher::suspending() Note that QFuture*::isPaused() now corresponds to (isSuspending() || isSuspended()). [ChangeLog][Deprecation Notice] Deprecated pause-related APIs of QFuture and QFutureWatcher. Added alternatives having "suspend" in the name instead. Change-Id: Ibeb75017a118401d64d18b72fb95d78e28c4661c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Do not multithread if already in a global threadpool threadAllan Sandfeld Jensen2020-06-032-0/+26
| | | | | | | | | | This can lead to a deadlock if we block all the worker threads, waiting for the worker threads to finish. Pick-to: 5.15 Fixes: QTBUG-84619 Change-Id: I92b7f96007897d86ece0c34223bab0df4ccbed9a Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Return correct threadId in all casesSamuli Piippo2020-05-301-10/+1
| | | | | | | | | | | | | If the assembler code cannot be used to retrieve the threadId, always use pthread_self() for it. QObject uses QThread::currentThreadId() and QThreadData::threadId to match threads, which makes address of the currentThreadData unsuitable as the thread id. Reading the threadId from currentThreadData is slower than calling pthread_self(), as tested on Aarch64 linux and x86_64 QNX. Change-Id: If9afc8ed2810ad1e04bd42ead8f40b43ef3bac30 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add a way of notifying QFutureWatcher when pause is in effectSona Kurazyan2020-05-297-16/+82
| | | | | | | | | | | | | | | | | | | | | | | | Because setting QFutureInterface to paused state does not mean that the computations that are already in progress will stop immediately, it may be useful to get notified when pause actually takes effect. Introduced the QFutureWatcher::suspended() signal, to be emitted when there are no more computations in progress, and no more result ready or progress reporting signals will be emitted, i.e. when pause took effect. Added {QFuture, QFutureWatcher}::isSuspended() methods for checking if pause took effect. QtConcurrent will now to send QFutureCallOutEvent::Suspended event when the state is paused and there are no more active threads. [ChangeLog][QtCore][QFutureWatcher] Added a new QFutureWatcher::suspended() signal, to be emitted when pause took effect, meaning that there are no more computations in progress. Added {QFuture, QFutureWatcher}::isSuspended() methods for checking if pause took effect. Fixes: QTBUG-12152 Change-Id: I88f2ad24d800cd6293dec63977d45bd35f9a09f0 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Don't queue events in QFutureWatcher when pause is requestedSona Kurazyan2020-05-272-26/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When QFutureWatcher (or QFutureInterface) is paused, it doesn't mean that it will take effect immediately: the pending tasks may still be in progress and keep reporting results. At the moment QFutureWatcher will queue those events and report only with the next resume. This behavior is wrong, QFutureWatcher should not decide when to report events, the sender should decide when is the right time. There's no benefit in reporting already happened events with delay. Because of this, even the pause event itself was being reported after resume. Fixed the behavior by removing the logic of queueing events when the state is set to "paused". It seems unlikely that the users of QFutureWatcher rely on reporting events with delay. [ChangeLog][Important Behavior Changes][QtCore] QFutureWatcher will not immediately stop delivering progress and result ready signals when the future is paused. At the moment of pausing there may be still computations that are in progress and cannot be stopped. Signals for such computations will be still delivered after pause, instead of being postponed and reported only after next resume. Fixes: QTBUG-12152 Change-Id: I9f0b545ac096578c52cc72d60575c018c01e3368 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Add support of cancellation handler callbacks to QFutureSona Kurazyan2020-05-154-18/+127
| | | | | | | | | Added QFuture::onCanceled() method, for attaching handlers to be called when the QFuture gets canceled. Change-Id: I1f01647d6173ba0c1db6641e14140108b33ac7c4 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add support of connecting signals to QFutureSona Kurazyan2020-05-152-1/+124
| | | | | | | | | | | Introduced QtFuture::connect(sender, signal) function returning a QFuture object, which is resolved when the signal is emitted. Task-number: QTBUG-81589 Change-Id: Idbe301eb247b468b9b34f3470c3359d6a7af2f3a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QRunnable::ref use in QThreadPoolAllan Sandfeld Jensen2020-05-072-26/+44
| | | | | | | | | | | | | | | | The reference counter could only ever be -1, 0 or 1, as an autoDeleted QRunnable can only be in a single thread pool. This commits keeps the reference counting for now, but asserts sanity, simplifies locking and fixes a leak. Pick-To: 5.15 Fixes: QTBUG-20251 Fixes: QTBUG-65486 Change-Id: I4de44e9a4e3710225971d1eab8f2e332513f75ad Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix docJarek Kobus2020-04-271-3/+3
| | | | | Change-Id: I0df2a430b451718e2fefdaa1632b81e2d16107cc Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* QFuture: the result type doesn't have to be a default-constructibleVitaly Fanaskov2020-04-231-13/+2
| | | | | | | | | | | Added asserts to insure the invariant declared in the documentation. Canceled future object is not valid, hence we don't need to handle this case separately. Fixes: QTBUG-83389 Change-Id: Ib0653ef40cd3135574a91740e4ce2c6dc4da8a71 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Make continuations work with move-only typesSona Kurazyan2020-04-181-26/+78
| | | | | | | | | | Use the move-only versions of result reporting and getting operations, if the type of QFuture is not copyable. Task-number: QTBUG-81941 Change-Id: Ic9fa978380e2c24e190e68d974051a650b0e5571 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* Move larger code examples in QFuture docs into snippetsSona Kurazyan2020-04-171-72/+5
| | | | | | Change-Id: I77b943124ac9c82f54b0c38e9437b9415604c21a Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* Add an example of error handling of QFuture without using exceptionsSona Kurazyan2020-04-171-6/+28
| | | | | | | | | Also fixed a few unrelated typos in docs. Task-number: QTBUG-83236 Change-Id: I776cda8f0ef4de6c4a93e94092dc19e94d1884c8 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-082-12/+14
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * No-thread: Don’t assert in ~QThreadData()Morten Johan Sørvig2020-04-031-0/+2
| | | | | | | | | | | | | | | | The no-thread build is not maintaining the QThreadData refcount. Change-Id: I80ce4151b8da9391764ed3d820943dcac0d70999 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
| * 64-bit atomics: fix bad copy/paste in macro definitionsThiago Macieira2020-03-201-12/+12
| | | | | | | | | | | | Fixes: QTBUG-82864 Change-Id: I35d5bcc92b2e4bddaacbfffd15fc42d054fcb2b1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Add support of failure handler callbacks to QFutureSona Kurazyan2020-04-014-1/+291
| | | | | | | | | | | | | | | | | | Added QFuture::onFailed() method, which allows attaching handlers for exceptions that may occur in QFuture continuation chains. Task-number: QTBUG-81588 Change-Id: Iadeee99e3a7573207f6ca9f650ff9f7b6faa2cf7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Store QFuture exceptions as std::exception_ptrSona Kurazyan2020-04-015-61/+29
| | | | | | | | | | | | | | | | | | | | | | Replaced the internal ExceptionHolder for storing QException* by std::exception_ptr. This will allow to report and store exceptions of types that are not derived from QException. Task-number: QTBUG-81588 Change-Id: I96be919d8289448b3e608310e51a16cebc586301 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | QFuture - add ability to move results from QFutureTimur Pocheptsov2020-03-316-25/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QFuture's original design pre-dates C++11 and its introduction of move semantics. QFuture is documented as requiring copy-constructible classes and uses copy operations for results (which in Qt's universe in general is relatively cheap, due to the use of COW/data sharing). QFuture::result(), QFuture::results(), QFuture::resultAt() return copies. Now that the year is 2020, it makes some sense to add support for move semantics and, in particular, move-only types, like std::unique_ptr (that cannot be obtained from QFuture using result etc.). Taking a result or results from a QFuture renders it invalid. This patch adds QFuture<T>::takeResults(), takeResult() and isValid(). 'Taking' functions are 'enabled_if' for non-void types only to improve the compiler's diagnostic (which would otherwise spit some semi-articulate diagnostic). As a bonus a bug was found in the pre-existing code (after initially copy and pasted into the new function) - the one where we incorrectly report ready results in (rather obscure) filter mode. Fixes: QTBUG-81941 Fixes: QTBUG-83182 Change-Id: I8ccdfc50aa310a3a79eef2cdc55f5ea210f889c3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Make QFuture::d privateSona Kurazyan2020-03-231-2/+10
| | | | | | | | | | | | Change-Id: I5820fa1d6d0f003a7cb95db115ef90b32f380a79 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Clean-up the duplicate code in QFuture and QFutureWatcherSona Kurazyan2020-03-233-135/+69
| | | | | | | | | | | | | | | | | | | | | | | | QFuture<void> and QFutureWatcher<void> are specialized to not contain any of result fetching methods, but otherwise they share almost the same implementation with QFuture<T> and QFutureWatcher<T> respectively. This change unifies their implementations to get rid of unnecessary code duplication. Change-Id: I9494ddc58c6db192c66edb988105927da6d61a3b Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-181-7/+12
|\| | | | | | | Change-Id: Ia79c2457f20f3428ef1b4358c1094e8dc1bbc33e
| * Fix memory leak on new QThreadPool::tryStart versionAllan Sandfeld Jensen2020-03-171-7/+12
| | | | | | | | | | | | | | | | Also documents the ownership of the traditional tryStart better, and remove a redundant check. Change-Id: I06202465b782926724fa33a901d08c1626f87373 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* | Add support for attaching continuations to QFutureSona Kurazyan2020-03-057-7/+645
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added QFuture::then() methods to allow chaining multiple asynchronous computations. Continuations can use the following execution policies: * QtFuture::Launch::Sync - the continuation will be launched in the same thread in which the parent has been executing. * QtFuture::Launch::Async - the continuation will be launched in a new thread. * QtFuture::Launch::Inherit - the continuation will inherit the launch policy of the parent, or its thread pool (if it was using a custom one). * Additionally then() also accepts a custom QThreadPool* instance. Note, that if the parent future gets canceled, its continuation(s) will be also canceled. If the parent throws an exception, it will be propagated to the continuation's future, unless it is caught inside the continuation (if it has a QFuture arg). Some example usages: QFuture<int> future = ...; future.then([](int res1){ ... }).then([](int res2){ ... })... QFuture<int> future = ...; future.then([](QFuture<int> fut1){ /* do something with fut1 */ })... In the examples above all continuations will run in the same thread as future. QFuture<int> future = ...; future.then(QtFuture::Launch::Async, [](int res1){ ... }) .then([](int res2){ ... }).. In this example the continuations will run in a new thread (but on the same one). QThreadPool pool; QFuture<int> future = ...; future.then(&pool, [](int res1){ ... }) .then([](int res2){ ... }).. In this example the continuations will run in the given thread pool. [ChangeLog][QtCore] Added support for attaching continuations to QFuture. Task-number: QTBUG-81587 Change-Id: I5b2e176694f7ae8ce00404aca725e9a170818955 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devLars Knoll2020-02-284-19/+19
|\| | | | | | | Change-Id: I469b0501cc65fc5ce4d797a69ae89405cc69c7f8
| * Improve argument name for std::function argumentAllan Sandfeld Jensen2020-02-264-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | Less \a fun though. Note using references in this API would just duplicate the API, but still end up with a copy when creating the QRunnable. By having the copy apparent directly in the API, we not only save the duplication, we also hint to the caller to use move if they want to avoid a copy. Change-Id: If11476d4b38853839c1e87e0339807a1798fc875 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-261-6/+0
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/bearermonitor/CMakeLists.txt examples/network/CMakeLists.txt src/corelib/tools/qlinkedlist.h src/sql/kernel/qsqldriver_p.h src/sql/kernel/qsqlresult_p.h src/widgets/kernel/qwidget.cpp src/widgets/kernel/qwidget_p.h tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp tests/auto/tools/moc/allmocs_baseline_in.json Change-Id: I21a3c34570ae79ea9d30107fae71759d7eac17d9
| * Doc: Fix documentation warnings for Qt CoreTopi Reinio2020-02-251-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - QCborError: Classes cannot relate to header files; use \inheaderfile instead and link to the class from header file documentation. - QRecursiveMutex: QDoc doesn't allow shared documentation comments for duplicating \fn docs between the base and deriving classes. Remove the sharing, the function documentation is available under 'All Members' doc for QRecursiveMutex. - QMultiMap: unite() and one overload of insert() were not recognized because their definitions in the same header file interfered with QDoc - use Q_CLANG_QDOC macro to comment them out, and tag \fn comments to ensure that the function documentation is matched. Change-Id: Ic96869904a72d92453e4ffa6901000147571969b Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-02-134-0/+66
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/boxes/scene.h src/corelib/Qt5CoreMacros.cmake src/corelib/Qt6CoreMacros.cmake src/network/ssl/qsslsocket.cpp src/network/ssl/qsslsocket.h src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp src/testlib/CMakeLists.txt src/testlib/.prev_CMakeLists.txt tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp Disabled building manual tests with CMake for now, because qmake doesn't do it, and it confuses people. Done-With: Alexandru Croitor <alexandru.croitor@qt.io> Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
| * Add a constructor for QRunnable from anonymous functionsAllan Sandfeld Jensen2020-01-314-0/+66
| | | | | | | | | | | | | | | | | | | | This makes it easier to create one without having to create a derivative class. The patch also adds a path to avoid using QRunnable directly in QThreadPool. Change-Id: I9caa7dabb6f641b547d4771c863aa6ab7f01b704 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* | Remove comments about destructors needing to be emptyJan Arve Sæther2020-02-111-1/+0
| | | | | | | | | | | | | | | | Not important, but removes some ### Qt6 comments from my radar Change-Id: Ifd1bf44c44ece8fa1314d3c7e0e95d1bd37ae0ea Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-283-4/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Leander Beernaert <leander.beernaert@qt.io> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
| * QThread::setPriority() Warn about invalid parameter on all platformsFriedemann Kleint2020-01-272-3/+5
| | | | | | | | | | | | | | | | | | | | | | InheritPriority may not be set, but the warning only occurs on Windows. Move the warning to the public class. Change-Id: I51d401300f840e4c1396c2c30182e49ed45d60d2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * Doc: Replace some usages of 0/zero/null with \nullptrSze Howe Koh2020-01-271-1/+1
| | | | | | | | | | Change-Id: Ibe7de11fc6fc41477c35e7d653c6a911855deabb Reviewed-by: Paul Wicking <paul.wicking@qt.io>