summaryrefslogtreecommitdiffstats
path: root/src/concurrent
Commit message (Collapse)AuthorAgeFilesLines
* Use universal references in QtConcurrentSona Kurazyan2020-09-308-186/+230
| | | | | | | | | | | | | | Changed QtConcurrent algorithms to take the passed sequences as universal references, where it makes sense. In addition to avoiding to create extra copies when passing rvalues, this change allows passing temporary container adaptors to QtConcurrent::map (e.g. see the example in the ticket and the new test-cases). Task-number: QTBUG-83170 Change-Id: Ia7c0833f4ec1d860294fa5214cd53934b65ff084 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Improve docs for QtConcurrent::{filter, blockingFilter}Sona Kurazyan2020-09-291-6/+18
| | | | | | Change-Id: Ibe3a038ad6853da1a6c9246b1157cd7ada4b9f32 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix QtConcurrent algorithms to work with temporary sequencesSona Kurazyan2020-09-283-26/+25
| | | | | | | | | | | | | | | | QtConcurrent algorithms are making an internal copy of the passed sequence, to make sure it won't be destroyed before the execution is finished. However, they were using iterators of the originally passed sequence. So, if the original sequence is deleted, QtConcurrent algorithms would use invalid iterators to a deleted sequence. This might work with Qt containers thanks to implicit-sharing, but with other containers will lead to unexpected results. Fixed them to work on the internal copy of the original sequence. Change-Id: I1d68692ed9746223c85f51bb05977bc1443b681d Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-231-3/+3
| | | | | | | | | | | Modify special case locations to use the new API as well. Clean up some stale .prev files that are not needed anymore. Clean up some project files that are not used anymore. Task-number: QTBUG-86815 Change-Id: I9947da921f98686023c6bb053dfcc101851276b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix some qdoc warnings: QtConcurrent functors and exceptionsVolker Hilsheimer2020-09-222-18/+4
| | | | | Change-Id: I32e45c85cedb74a6dcbd99930910b730f1160fae Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Correct link errors qtbaseNico Vertriest2020-09-211-1/+1
| | | | | | Task-number: QTBUG-86295 Change-Id: I27f6bbdadffb08a8794520a14dfe0e2334979575 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Add links to Qt 6 changes files from module indexPaul Wicking2020-09-181-0/+4
| | | | | | Task-number: QTBUG-84051 Change-Id: Iac25df135c9d73a990b41243e08cd38ea78296a4 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Doc: Add porting guide documentsPaul Wicking2020-09-161-0/+46
| | | | | | | | Also add existing such docs to the new document group Task-number: QTBUG-84051 Change-Id: I76f033f0846e09943f249d2beeb1606869eef382 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Get rid of qtconcurrentexception.hLars Knoll2020-09-103-67/+0
| | | | | | | | It only contained two aliases that have been deprecated since 2012. Change-Id: I6f65aa5144aca2d8d99f8a6e586b805f685afad2 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Mention QPromise on QtConcurrent pageJarek Kobus2020-09-011-0/+4
| | | | | | | Change-Id: I82d3ddd4a9129694d6dedcc742165cb2af135527 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QtConcurrent: Add documentation for runWithPromise()Jarek Kobus2020-08-266-12/+250
| | | | | | Task-number: QTBUG-84702 Change-Id: Ic8233aeffbdbd1420bdbde7ad7d03f25cd438ea8 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix include in public headerKai Koehne2020-08-231-1/+1
| | | | | | | | We shouldn't rely on include path containing also /QtCore Task-number: QTBUG-82615 Change-Id: I0f98f6097865cc5aa2c2fc9a0fabf2c4513b7afe Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix the doc exampleJarek Kobus2020-08-191-1/+1
| | | | | | | | The intention is to return list containing two items, not just one. Change-Id: I96f3ce939f2ef6db6bdac5d9165bb7814ebfa91a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtConcurrent: Introduce runWithPromise()Jarek Kobus2020-08-192-2/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The differences to run() method: 1. The passed function should have additional argument QPromise<T> &, declared as a first argument. 2. The return value of the function must be void. Result reporting should be done through passed QPromise<T> &promise argument. 3. By default, runWithPromise() doesn't support functors with overloaded operator()(). In case of overloaded functors the user needs to explicitly specify the result type as a template parameter passed to runWithPromise, like: struct Functor { void operator()(QPromise<int> &) { } void operator()(QPromise<double> &) { } }; Functor f; runWithPromise<double>(f); // this will select the 2nd overload Task-number: QTBUG-84702 Change-Id: Ie40d466938d316fc46eb7690e6ae0ce1c6c6d649 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-311-3/+3
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtConcurrent: Get rid of multi-inheritance inside RunFunctionTaskBaseJarek Kobus2020-07-141-12/+14
| | | | | | | | Use aggregation instead. Prepare for using QPromise instead of QFutureInterface. Task-number: QTBUG-84702 Change-Id: Ic88564dca8c83a178a281cb843032292210a6d25 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtConcurrent: Get rid of code repetition for RunFunctionTask::run()Jarek Kobus2020-07-132-34/+21
| | | | | | Change-Id: If270982e54d2b11be00c71b9d012af629d181dfe Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use QList instead of QVector in qtbaseJarek Kobus2020-07-074-19/+18
| | | | | | | | Fixes all other QVector occurrences Task-number: QTBUG-84469 Change-Id: I5f9311298d341a9a3061a6a640539583d1618939 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Avoid use of Q_UNUSED by eliminating the parameter namesLars Schmertmann2020-07-031-4/+2
| | | | | | | | | This change only happens to files touched by the commit to add missing ; to Q_UNUSED. Task-number: QTBUG-82978 Change-Id: I10e6993a2bb3952cf9a262708b8573550e0dbe63 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Doc: Update docs with cmake package informationNico Vertriest2020-06-301-0/+1
| | | | | | Task-number: QTBUG-85179 Change-Id: I70dda9b906ecd0b8d8f4d88b0562af8e6c428143 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use QList instead of QVector in QtConcurrentJarek Kobus2020-06-225-5/+5
| | | | | | | Task-number: QTBUG-84469 Change-Id: I99e41c1fef5459d7358b20a97a1dbefcd43bb4e5 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Reuse the non blocking implementation for blocking oneJarek Kobus2020-06-052-183/+193
| | | | | | | | | | | | | | | | | Replace the implementation of blockingMappedReduced(): after calling non-blocking version of mappedReduced() we are getting the future object, so we may call in sequence result(), which will block and return the result when the all tasks are done. The same is done with blockigMapped(), which calls blockingMappedReduced() with a custom reduce function. Looks like with this pattern we can reuse the non-blocking version for implementing blocking version of mapped / filtered methods. Task-number: QTBUG-83918 Change-Id: I7f240cfbd04834d551ff79d717b72194a26996d7 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Deprecate the pause-related APIs of QFuture* classesSona Kurazyan2020-06-042-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add a way of notifying QFutureWatcher when pause is in effectSona Kurazyan2020-05-292-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Make threadCount a const member of ReduceKernelJarek Kobus2020-05-281-1/+2
| | | | | Change-Id: I8e75263d3e02a6e6a20520ebecfdb4e40b562bbf Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Pass the thread pool into ReduceKernelJarek Kobus2020-05-283-7/+7
| | | | | | | | | This was overlooked when enabling setting a custom thread pool for various concurrent methods. Fixes: QTBUG-53465 Change-Id: I189a7776fa02bbc3e995538cc154a7246ad1ad7a Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Pass the thread pool into BlockSizeManagerJarek Kobus2020-05-282-4/+4
| | | | | | | | | This was overlooked when enabling setting a custom thread pool for various concurrent methods. Fixes: QTBUG-53465 Change-Id: I8b0a0086e46639639051fe99cf52d049f7bb3bb2 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Make some members of IterateKernel constJarek Kobus2020-05-281-5/+6
| | | | | Change-Id: Ifeabebcbb7212a8c2799a37665b290983fd64105 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Document how to use CMake for Qt ConcurrentKai Koehne2020-05-264-4/+20
| | | | | | Task-number: QTBUG-73058 Change-Id: I11398c5837b45ccacb9232609317213133ef20ea Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Licenses: Remove reference to change in Qt 5.4Kai Koehne2020-05-221-3/+2
| | | | | | | Qt 5.4 is not documented anymore since quite some time. Change-Id: I6811ead502178f7acbed8cf450e42d7fd33ae29b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Enable setting custom QThreadPool for QtConcurrent methodsJarek Kobus2020-05-1810-343/+1491
| | | | | | Task-number: QTBUG-53465 Change-Id: Icff05d5f65dce453ff702502b85c35e20fca86a9 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Get rid of virtual inheritance from ThreadEngineBaseJarek Kobus2020-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | The virtual inheritance causes the issue, when adding new, non-default constructor to the base ThreadEngineBase class. It looks like classes derived from it can't use the non-default constructor, even when it's called explicilty from the subclass. Instead, the default constructor of the ThreadEngineBase class is always required during compilation and called on runtime. In addition, the only sensible use of the virtual inheritance is the multiple inheritance, but apparently it looks like there is no single class in Qt which would multi inherit from the ThreadEngineBase class, so this change shouldn't have any bad side effects. This justifies the current lack of info on why it was introduced originally ages ago. Change-Id: I08266e6f6865d938d1b1e4243ef94d2c02c3a886 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Improve Map|Map-Reduce and Filter|Filter-Reduce implementationKarsten Heimrich2020-04-1411-389/+336
| | | | | | | | | | | | | * support lambda expressions * remove the need to specify result_type * use std::invoke to apply map|filter function * remove usage of FunctionWrapper* and createFunctionWrapper Task-number: QTBUG-33735 Task-number: QTBUG-82646 Change-Id: Ibcbe4278f0742c29182bd506081db0abb516f85f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QTaskBuilder::spawn: add an overload that doesn't return a future objectVitaly Fanaskov2020-04-144-0/+40
| | | | | | Fixes: QTBUG-83175 Change-Id: Idf85e47a2732742884272200d5c753805eaa640b Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Resolve Qt6 TODO items, replace Median and BlockSizeManagerKarsten Heimrich2020-04-093-181/+14
| | | | | | | | | | | * Replaces the, only internaly used, implementation of template class Median with a fixed size none templated version. * Replaces BlockSizeManager with an updated BlockSizeManager V2, but keeping the original name. * adapt the auto-test to take the fixed size array into account Change-Id: If76cb944676c4a06a7566ad0bc37ded25b81c70c Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Remove some dead codeKarsten Heimrich2020-04-092-46/+0
| | | | | | | Change-Id: I526d9baee260f018cec6076595a28be8596b6395 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* StoredFunctionCall: simplify runFunctor implementationVitaly Fanaskov2020-04-071-11/+4
| | | | | | Task-number: QTBUG-82383 Change-Id: Ib8e196106c80e8f3aba1ff7d0c8b76a547c648da Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix potential race condition in QtConcurrent blocking methodsSona Kurazyan2020-04-032-3/+7
| | | | | | | | | | | QtConcurrent::blocking*() methods are using the ExceptionStore directly, which is not thread safe. In case if there's an exception thrown from multiple threads there may be a race condition. Added a lock to avoid that. Change-Id: I5de9928f91f5f43951b9bf9c4594694dc0ca0328 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake: Regenerate projects after .pro files were modifiedAlexandru Croitor2020-04-031-2/+2
| | | | | | Change-Id: If6aec596bf68b209b42e0728dd6857eec8c261be Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Store QFuture exceptions as std::exception_ptrSona Kurazyan2020-04-011-1/+1
| | | | | | | | | | | 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-311-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QtConcurrent: add fluent interface to configure a task before runVitaly Fanaskov2020-03-2911-11/+635
| | | | | | | | Task-number: QTBUG-82950 Change-Id: I449da938b6b501a7646b3425edde5c880d6ca87e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* QtConcurrent::run: accept more then five function's argumentsVitaly Fanaskov2020-03-114-3020/+76
| | | | | | | | | | | | | | [ChangeLog][Potentially Source-Incompatible Changes] QtConcurrent::run has the following signatures: run(Function &&f, Args &&...args) and run(QThreadPool *pool, Function &&f, Args &&...args). If f is a member pointer, the first argument of args should be an object for which that member is defined (or a reference, or a pointer to it). See the documentation for more details. Fixes: QTBUG-82383 Change-Id: I18f7fcfb2adbdd9f75b29c346bd3516304e32d31 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtConcurrent: filter- and map-reduce with initial valueMårten Nordheim2020-03-047-14/+521
| | | | | | | | | | | | | | | | | It takes any type which is implictly covertible to the result type and then converts it in the outer-layers. Then it passes it into the deeper layers and initiales the result value. One drive-by fix with a missing letter in the documentation. [ChangeLog][QtConcurrent] QtConcurrent::mappedReduce and QtConcurrent::filteredReduced, as well as their blocking variants, now optionally take an initial value. Fixes: QTBUG-73240 Change-Id: I7a80d96693cfa3374847c75c75b3167664609c1a Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove QLinkedListSona Kurazyan2020-02-191-1/+1
| | | | | | | | | | | | | QLinkedList has been moved to Qt5Compat. Remove and stop mentioning it in docs, examples (the docs & examples for QLinkedList itself will be moved to Qt5Compat) and remove the corresponding tests. Also remove QT_NO_LINKED_LIST, since it's not needed anymore. Task-number: QTBUG-81630 Task-number: QTBUG-80312 Change-Id: I4a8f1105cb60aa87e7fd67e901ec1a27c489aa31 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Regenerate projects to correctly handle private dependenciesAlexandru Croitor2020-02-051-0/+2
| | | | | | | Change-Id: I7d84bc9962bff5c89a90367ae704974c6ce2ec89 Reviewed-by: Qt CMake Build Bot Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Regenerate src/*Alexandru Croitor2019-11-141-3/+3
| | | | | | Change-Id: I0314b4faa1e4860e86198eea4189987e527dfec2 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Regenerate everything under ./srcAlexandru Croitor2019-11-121-3/+0
| | | | | | | Change-Id: Ibdbdc17f8c2ee41356f490dd839a47e1bcf4c586 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Qt CMake Build Bot
* Merge remote-tracking branch 'origin/dev' into wip/cmakeAlexandru Croitor2019-10-141-10/+10
|\ | | | | | | Change-Id: I4a78428a8ea273b6960792e3b8043f816fa37fcf
| * QtConcurrent: fix warning about function parameters shadowing class membersVolker Hilsheimer2019-10-081-10/+10
| | | | | | | | | | | | | | | | No functional change. Change-Id: I76aa01e8eb044c794d518ca72e6861cf95060dfc Fixes: QTBUG-79071 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>