summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qresultstore.h
Commit message (Collapse)AuthorAgeFilesLines
* QResultStore: add emplaceResult<T>()Marc Mutz2023-03-311-4/+9
| | | | | | | | | ... use it in moveResult(). Task-number: QTBUG-112270 Change-Id: I1233a710801d73c9153439b74a7a3900d2d9e39d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QResultStore::moveResult(): refuse to move from lvaluesMarc Mutz2023-03-311-0/+2
| | | | | | | | | | | | | The T&& result argument is deduced, therefore result is a Universal Reference and as such can bind to lvalues, not just rvalues. If passed an lvalue, the function would happily move away from it, which is not what the doctor prescribed. Catch the attempt with a static assertion. Pick-to: 6.5 Change-Id: Iff8c1abd5dcb1043ed94ba76570be5ba3d6f92da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QResultStore: use unconditional move() in moveResult()Marc Mutz2023-03-311-1/+1
| | | | | | | | | | | | | | | | | | | If the move can fail, so can most likely the copy. Use of move_if_noexcept() therefore trades a faster potentially-throwing operation for a slower potentially-throwing operation. It is true that a throwing move ctor may leave the source object in a partially-formed state while the copy ctor may not (exceptions prove the rule, hello auto_ptr), but we shouldn't pessimize lazy coders (missing noexcept) to cater for borderline-buggy code (throwing move ctor that doesn't provide the strong exception guarantee). Yes, you can construct such situations (and something as simple as std::array<std::pmr::string, 10> is already affected), but we don't cater for these anywhere else in Qt, so why do it here? Change-Id: I728af8e87ed86f24326530f704a48df1f728ac98 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QResultStore: remove unused includeGiuseppe D'Angelo2022-03-171-1/+0
| | | | | | Change-Id: I829e98af4f46156926a1ee68bddf4399bc557439 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Mark ResultStoreBase as finalSona Kurazyan2022-01-241-1/+1
| | | | | | | | | | | | | The class is not intended for inheriting from it (see also e5029063057c38297f188ccfefef7b1bcd781a76), so we can mark it as final to explicitly forbid this. The tests were still using it as a base class to clean the results during destruction, so fix them accordingly. Task-number: QTBUG-99883 Pick-to: 6.3 Change-Id: I4a7ee3e2b462bd704e4b5a95ed733144805d6e5b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add a note for making ResultStoreBase's internal members privateSona Kurazyan2022-01-211-1/+2
| | | | | | | | | | | There's no class inheriting from ResultStoreBase (and likely won't be), so the destructor was marked to be made non-virtual in Qt 7. For the same reason, the internal members don't need to be protected, and the class shouldn't have "Base" in its name. Add a note about it. Task-number: QTBUG-99883 Change-Id: I00d7a96d99d2c326d29bd421235a15d68b4d4e5c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* corelib: Fix typos in source code commentsJonas Kvinge2021-10-121-2/+2
| | | | | | Pick-to: 6.2 Change-Id: Ic78afb67143112468c6f84677ac88f27a74b53aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Don't report results when the results list is emptySona Kurazyan2021-07-271-0/+7
| | | | | | | | | | | | | | | | | | When inserting items into the result store, a ResultItem is created, which stores a pointer to the results list and their size. If the size of the ResultItem is set to 0, it means that a single result is stored. In case of trying to report results via an empty list, the size is 0, so result store treats it as a single result. Added checks before storing the results to make sure that the result list isn't empty. Note that empty lists are allowed in some cases for the filter mode, because ResultStoreBase::addResults() knows how to handle those cases correctly. Task-number: QTBUG-80957 Pick-to: 5.15 6.1 6.2 Change-Id: I399af4c3eef6adf82fea5df031fe9a9075006b1f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFuture: put the result store and the exception store in a unionSona Kurazyan2021-06-121-0/+1
| | | | | | | | | | | | | | QFuture doesn't need both at the same time, calling QFuture::result(s) either returns a result or throws an exception. Store result and exception stores in a union, to reduce the memory. Also added a note for making the ResultStoreBase destructor non-virtual in Qt 7. Task-number: QTBUG-92045 Change-Id: I7f0ac03804d19cc67c1a1466c7a1365219768a14 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Reject overwrites by the same index in QPromise::addResult()Andrei Golubev2020-10-131-1/+22
| | | | | | | | | | | | One can call addResult(value, index) twice and consequently set the value twice by the same index. This seems rather strange and probably should not be allowed. This commit rejects setting results when there's already a valid result by that index. Consequently, this fixes memory leaks caused by N-times-called addResult(..., index) Fixes: QTBUG-86828 Change-Id: I77494f2cb73ce727ffad721cfcdcaa420899eb25 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Clear pending results in ResultStoreAndrei Golubev2020-10-091-9/+18
| | | | | | | | Pending results were never cleared by result store. This led to memory leaks when the results never transitioned to "visible" results Change-Id: I674302eb51542ad5f4d918da68d616428c73ae9f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Use QList instead of QVector in corelibJarek Kobus2020-06-251-12/+10
| | | | | | | | | | 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>
* QFuture - add ability to move results from QFutureTimur Pocheptsov2020-03-311-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* More nullptr usage in headersKevin Funk2019-03-141-2/+2
| | | | | | | | | | | Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* doc: Fix all clang parse errors in QtBase during PCH buildMartin Smith2018-11-051-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This update eliminates ALL parsing errors when clang parses the Qt headers to build the precompiled header qdoc needs. These errors are often cases where an old use of Q_QDOC no longer works because clang sees the enclosed fake declarations as erroneous. In a few cases, clang reported errors because two dummy function declartations under the Q_CLANG_QDOC guard were indistinguishable, so one of them was removed, and the documentation was patched accordingly. Using the macro Q_DECLARE_INTERFACE(...) causes clang to report errors because the class parametewr is abstract. These uses of the macro are not needed, so they are removed with #ifndef Q_CLANG_QDOC. Some declarations of default GL types that had been provided for qdoc were no longer needed, so they are removed. Now there are some member function signatures in QDBusPendingReply and QDBusPendingCall that have very long template clauses and qualifiers in their signatures. These unwieldy signatures will be unnecessary in the documentation and will look bad there, but for now they are correct. The ultimate solution will be to add a metacommand to qdoc, something like \simplify-signature to tell qdoc to generate the documentation for these member functions without the long template caluses and qualifiers. Change-Id: I012cf17a544fbba2ebc71002f31bdc865119bb8e Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* Make QT_NO_FUTURE a featureUlf Hermann2017-12-191-6/+2
| | | | | | | | | | | ... and make sure we can compile without it. In particular, Qt Concurrent depends on QFuture, so we specify it as a condition, and QtConcurrentException should not depend on future but on concurrent. Change-Id: I65b158021cecb19f227554cc8b5df7a139fbfe78 Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-2/+2
| | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-201-48/+16
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qfilesystemengine_win.cpp src/gui/text/qdistancefield.cpp src/plugins/platforms/xcb/qxcbconnection.h Change-Id: I1be4a6f440ccb7599991159e3cb9de60990e4b1e
| * Fix UB in QFutureInterface: invalid casts from ResultStoreBase to ResultStore<>Olivier Goffart2017-03-061-48/+16
| | | | | | | | | | | | | | | | | | | | | | ResultStore never actually exists, only ResutStoreBase does. So casting to ResultStore<T> and calling its member functions is UB. Put the type dependent function as template member functions within ResultStoreBase and so we don't need QtPrivate::ResultStore anymore. Same goes for the iterator. Change-Id: I739b9d234ba2238977863df77fde3a4471a9abd2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Sprinkle Q_DECLARE_TYPEINFO on types used in containersGiuseppe D'Angelo2017-02-231-0/+2
|/ | | | | Change-Id: I6c71ed8c20cd5e785037ad25c2d3da8994e8e3a0 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>
* QtCore: Use Q_NULLPTR instead of 0 in all public headersMarc Mutz2015-07-011-2/+2
| | | | | | | | | This is in preparation of adding -Wzero-as-null-pointer-constant (or similar) to the headers check. Task-number: QTBUG-45291 Change-Id: I0cc388ef9faf45cbcf425ad0dc77db3060c104a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.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>
* 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>
* Whitespace cleanup: remove trailing whitespaceAxel Waggershauser2013-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-2/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.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>
* Replace macro qdoc with Q_QDOCDebao Zhang2013-01-081-2/+2
| | | | | | | | Both qdoc and Q_QDOC are used in source code, which looks not good. Change-Id: I4f3a71670278b0758d92bfa5db086a07e1b1acfd Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Fix for memory leak in ResultStoreChristian Strømme2012-10-181-1/+4
| | | | | | | | | | | In ResultStoreBase::addResults() it possible that the ResultItem we create is invalid (filter-mode enabled). Since an invalid ResultItem won't have any result data, we need to make sure that we don't allocate any data for it. Task-number: QTBUG-27224 Change-Id: Ic99b191db0e9dd4e29b64911f87d90a8148bb7a5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Move QtConcurrent::ResultStore as QtPrivate::ResultStore to QtCoreMarc Mutz2012-09-281-0/+238
No compatibility header needed. While this wasn't marked as private API, it wasn't documented, either. This is a prerequisite for moving QFuture to QtCore. Change-Id: I8e986e6e2a22fbe5cf08d0600ec39ae9ae993e20 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>