summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qdeadlinetimer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QDeadlineTimer: use new comparison helper macrosTatiana Borisova2024-04-181-16/+18
| | | | | | | | | | | Replace public friend operators operator==() and operator!=() of QDeadlineTimer to friend method comparesEqual(). Replace public friends operator<(),<=(),>(), etc of QDeadlineTimer to friend method compareThreeWay(). Task-number: QTBUG-120304 Change-Id: Ib855ccac9b31b54fe28b822f2985154608fefa27 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Mention QChronoTimer in API docsAhmad Samir2024-03-031-6/+7
| | | | | Change-Id: Iaf9fb31994f1580b2051dbd0b1b8eef2a218aa39 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* [docs] QDeadlineTimer: remove docs of a function that exists no moreMarc Mutz2023-12-131-5/+0
| | | | | | | | | | | | | | The _q_data() function was removed before 6.6, but the docs remained. Presumably qdoc doesn't care about non-existing \internal \fn's. Found while hunting for QPair uses to eliminate. Amends eac30fcb827e9bb1372e46290c060c833bd8ea67. Pick-to: 6.7 6.6 Change-Id: I73fdfe69d4158977a6a80eb2a5e790ada09fe85a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QDeadlineTimer: make the (Qt::TimerType) ctor explicitMarc Mutz2023-08-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt::TimerType is not a faithful representation of a QDeadlineTimer. It's missing the actual deadline, and so should not be allowed to participate in implicit conversions. Consider whether you'd like to see such code: foo.setTimeout(Qt::PreciseTimer); // HU??? So split the old (TimerType = CoarseTimer) ctor into an explicit default ctor (applying NSDMI to make it =default'able) and a new explicit (TimerType) ctor. [ChangeLog][Potentially Source-Incompatible Changes][QtCore] The QDeadlineTimer(Qt::TimerType) constructor is no longer implicit. To keep old source working, wrap the Qt::TimerType argument in QDeadlineTimer{}. This is backwards-compatible with older Qt versions. [ChangeLog][QtCore][QDeadlineTimer] The (Qt::TimerType) constructor is now explicit (was: implicit). Found in API-review. Pick-to: 6.6 Change-Id: I72aaaad5201bd288a6fd6af398573aaa9d0eda5a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDeadlineTimer: avoid a system call for timeout == 0Thiago Macieira2023-05-111-10/+32
| | | | | | | | | | | | | | | | | | The constructor's documentation already had the note saying that we could apply this optimization, but it wasn't there and looks like it never was. This only applies to the default constructor, which sets t1 to zero, which is the epoch. This could be a problem for an OS whose monotonic clock starts with negative values, but I don't know such an OS exists and this hasn't been a problem so far. This commit doesn't change the behavior of the old-style, non- std::chrono getters, because we always transform any negative remaining time to 0. It is only possible to observe it by asking the remaining time or the deadline using the std::chrono API. Change-Id: I6f518d59e63249ddbf43fffd175a3fc2911e91fb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDeadlineTimer: make it so any negative millisecond count is "forever"Thiago Macieira2023-05-111-7/+17
| | | | | | | | | | | | | | We have quite a few Qt API that assumes this, so making this change helps transitioning them to QDeadlineTimer. [ChangeLog][Important Behavior Changes] QDeadlineTimer will now interpret negative millisecond remaining times as "forever", instead of only the value -1. This brings the API closer in line with other API like QMutex. This change does not apply to the nanosecond counts in the API, nor to the API based on std::chrono. Change-Id: I6f518d59e63249ddbf43fffd175a3e5bead564ae Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDeadlineTimer: remove internal TimeReference classThiago Macieira2023-04-181-270/+46
| | | | | | | | | This removes all uses of QDeadlineTimer::t2 member in the .cpp (so it gets marked [[maybe_unused]]) and greatly simplifies the code. Change-Id: Ieec322d73c1e40ad95c8fffd17465bd50c1113ea Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QDeadlineTimer: use std::chrono::steady_clock everywhereThiago Macieira2023-04-181-114/+29
| | | | | | | | | | | | | | | This matches the work that was done for QElapsedTimer. The QDeadlineTimer::t2 member is now always 0. This also removes the last distinction of timer types. Originally I had intended to use CLOCK_MONOTONIC_COARSE on Linux[1], but that created more problems than was worth, so I abandoned the idea in 2016. [1] https://codereview.qt-project.org/c/qt/qtbase/+/159933 Change-Id: Ieec322d73c1e40ad95c8fffd17468b313798ef79 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QElapsedTimer: rewrite using std::chrono::steady_clock everywhereThiago Macieira2023-04-181-0/+21
| | | | | | | | | | | | | | This commit deletes the direct, low-level functionality that QElapsedTimer has carried since it was introduced. Everything now uses only std::chrono::steady_clock and std::chrono::nanoseconds. QDeadlineTimer temporarily still uses qt_gettime(), which is moved to qcore_unix.cpp. Task-number: QTBUG-110059 Change-Id: Ieec322d73c1e40ad95c8fffd174641a469b1eee5 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QElapsedTimer/Darwin: merge with the Unix implementationThiago Macieira2023-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Old versions of the Apple operating systems did not implement the POSIX realtime monotonic clock, so we used the Mach absolute timer. The LLVM libc++ implementation[1] unconditionally uses CLOCK_MONOTONIC_RAW on these OSes: * macOS >= 10.12 * iPhoneOS >= 10.0 * tvOS >= 10.0 * watchOS >= 3.0 Qt 6 doesn't support the latter two and the former two are much older than what we require, so we can use this functionality too. [1] https://github.com/llvm/llvm-project/blob/main/libcxx/src/chrono.cpp Change-Id: Ieec322d73c1e40ad95c8fffd174641c723b81be2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QElapsedTimer & QDeadlineTimer: use NSDMI for their two fieldsThiago Macieira2023-02-251-1/+0
| | | | | | Pick-to: 6.5 Change-Id: Ieec322d73c1e40ad95c8fffd174654d643c05097 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@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>
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Fix various documentation issues for Qt CoreTopi Reinio2020-10-311-3/+2
| | | | | | | Task-number: QTBUG-86295 Change-Id: I3bf7d4b1533d4fc81114d353b19beaf4ea9b93b2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix documentation for hidden friend operatorsVolker Hilsheimer2020-10-231-16/+8
| | | | | | | | At least for qdoc, hidden friends are class members. Change-Id: I6eaa21565937cd49c0905ee47b8b82b0c1765bc1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-2/+2
| | | | | | | | | | | | | | | | | 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>
* Fix minor errors in QDeadlineTimer docsEdward Welbourne2020-03-111-5/+5
| | | | | | Change-Id: I0f33094da29300ca8a609cfffd700c2a82d86ad1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-05-131-58/+382
|\ | | | | | | | | | | | | Conflicts: src/corelib/tools/qstring.cpp Change-Id: I81dbf90fc936c9bf08197baefa071117bddb1c63
| * Fix integer overflows in QDeadlineTimerKonstantin Shegunov2019-05-081-58/+382
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the deadline is far in the future, the conversions to nanoseconds or internal arithmetic may overflow and give an invalid object, thus the deadline may end up in the past. Added a test to the testlib selftest for sleep. [ChangeLog][QtCore][QDeadlineTimer] Fixed integer overflows leading to immediate timeouts. Task-number: QTBUG-69750 Change-Id: I9814eccdf9f9b3add9ca66ec3e27e10cd5ad54a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-12/+12
|/ | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix various documentation warningsTopi Reinio2018-11-061-0/+5
| | | | | | | | | | | | These include typos, marking functions as \internal, documenting trivial things, and fixing the function signatures passed to the \fn command. Task-number: QTBUG-71502 Change-Id: I24a9e1f7e1cdb39e5c31b99202bdd593c6b789ff Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Move literal code block to a separate fileCristian Maureira-Fredes2018-10-151-71/+14
| | | | | | | | | | | We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-071-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/corelib/doc/src/objectmodel/signalsandslots.qdoc src/plugins/platforms/cocoa/qcocoamenuloader.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp tests/auto/gui/image/qimage/tst_qimage.cpp Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Change-Id: I9bd24ee9b00d4f26c8f344ce3970aa6e93935ff5
| * QDeadlineTimer: Fix documentation typoAndre Hartmann2018-08-011-2/+2
| | | | | | | | | | Change-Id: If8f7766ca0698a3defdf9c59c44fb02a8a5b3b62 Reviewed-by: Martin Smith <martin.smith@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-07-021-0/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/cocoa/qnsview_dragging.mm src/plugins/platforms/ios/qiosinputcontext.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/tools/androiddeployqt/main.cpp Was moved from qttools into qtbase in 5.11. So re-apply 32398e4d here. tests/auto/corelib/global/qlogging/test/test.pro tests/auto/corelib/global/qlogging/tst_qlogging.cpp tests/auto/corelib/io/qfile/tst_qfile.cpp tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp tests/auto/corelib/thread/qthreadstorage/test/test.pro tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp tests/auto/widgets/kernel/qapplication/test/test.pro Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Done-with: Mårten Nordheim <marten.nordheim@qt.io> Done-with: Oliver Wolff <oliver.wolff@qt.io> Change-Id: Id970486c5315a1718c540f00deb2633533e8fc7b
| * Doc: Point to the SG-10 SD-6 as a requirement for C++14 featureThiago Macieira2018-06-161-0/+5
| | | | | | | | | | | | | | | | Task-number: QTBUG-68702 Change-Id: I04b94079b6da48f39a82fffd153568f8dab3ef1b Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Port QWaitCondition to QDeadlineTimerThiago Macieira2018-03-031-1/+0
|/ | | | | | | | | | Since pthread_cond_timedwait takes absolute time instead of relative time like most POSIX API, there's a small gain in performance here: we avoid an extra system call to get the current time. Task-number: QTBUG-64266 Change-Id: I25d85d86649448d5b2b3fffd1451138568091f50 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* doc: Correct remaining qdoc warnings in qdeadlinetimer.cppMartin Smith2018-01-061-8/+8
| | | | | | | | | clang required adding template clauses to \fn commands and in one instance, removing a formal parameter name from a \fn command. An instance of Q_QDOC was changed to Q_CLANG_QDOC in the include file. Change-Id: Ic7dab56705043d2db8578dfc002d2f41b927f756 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDeadlineTimer: round milliseconds up instead of downThiago Macieira2017-07-071-1/+1
| | | | | | | | | | | | | | | | | | | Code like: QElapsedTimer timer; timer.start(); QTest::qWait(30); QVERIFY(timer.elapsed() >= 30); is failing, because qWait sleeps in increments of 10 ms and the last chunk may be off by less than one millisecond, so we end up sleeping too little and thus returning before 30 ms have elapsed. This matches the QElapsedTimer::elapsed() code that rounds down: return nsecsElapsed() / Q_INT64_C(1000000); Task-number: QTBUG-61741 Change-Id: Ic3a088f9f08a4fd7ae91fffd14cea4a91d3f51a8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Core: Replace LGPL21 with LGPL license headerKai Koehne2017-03-281-13/+19
| | | | | | | | Also use canonical contact url. Change-Id: I43f8c6a2c4949ee0e054045bccc17d82575b072c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-161-2/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure configure.pri examples/widgets/painting/fontsampler/mainwindow.cpp examples/widgets/painting/fontsampler/mainwindow.h mkspecs/features/moc.prf src/corelib/global/qglobal.h src/gui/text/qtextdocument.cpp Change-Id: Ica65512e00871695190a14ccea5c275b0165f787
| * QDeadlineTimer: fix namespace for chrono literals in examplesMarc Mutz2016-11-301-2/+4
| | | | | | | | | | Change-Id: I6d39b4fe653cf89d2bd27af4b3f606d98ac83eba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Fix some qdoc-warningsFriedemann Kleint2016-11-231-21/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qtbase/src/corelib/kernel/qdeadlinetimer.cpp:343: warning: Cannot find 'setPreciseRemainingTime(...)' in '\fn' void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type) qtbase/src/corelib/kernel/qdeadlinetimer.cpp:459: warning: Overrides a previous doc qtbase/src/corelib/kernel/qelapsedtimer.cpp:86: warning: Unknown command '\ref' qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_2' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_3_0' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_1' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_0' in QSysInfo::MacVersion qtbase/src/corelib/kernel/qdeadlinetimer.cpp:175: warning: Missing parameter name qtbase/src/corelib/kernel/qdeadlinetimer.cpp:175: warning: No such parameter 'ForeverConstant' in QDeadlineTimer::QDeadlineTimer() qtbase/src/corelib/kernel/qdeadlinetimer.h:156: warning: No documentation for 'QDeadlineTimer::remainingTimeAsDuration()' qtbase/src/gui/painting/qcolor.cpp:796: warning: Undocumented parameter 'name' in QColor::QColor() qtbase/src/gui/painting/qcolor.cpp:802: warning: Undocumented parameter 'name' in QColor::QColor() Some errors in QDeadlineTimer remain due to qdoc not fully supporting templates. Change-Id: Ie7afd91c48048748eeda23c32056583c31fd7490 Reviewed-by: Nico Vertriest <nico.vertriest@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | doc: Upgrade QDeadlineTimer for clang-qdocMartin Smith2016-12-041-68/+27
|/ | | | | | | | | Duplicate qdoc comments removed for setPreciseRemainingTime(), remainingTime(), and deadline(). Added qdoc comments for swap(), and two new assignment operators. Also added a few parameter names. Change-Id: I5c19ca3bdef876019c5742397249ea9e0c066bf3 Reviewed-by: Martin Smith <martin.smith@qt.io>
* Doc: several minor doc issuesNico Vertriest2016-09-271-51/+37
| | | | | | | | - linking errors - parameter definition Change-Id: I879b38c159822900ab9851407f0e9067b318ca1f Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QDeadlineTimer: inline the isForever functionThiago Macieira2016-08-301-4/+2
| | | | | | | | The constructor that sets it is inline already, so there's no point in hiding this. Change-Id: I66707fdfe8eb460a9c72fffd146d8dbc35b13056 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Long live QDeadlineTimerThiago Macieira2016-08-151-0/+827
It's like QElapsedTimer, but marks a time in the future instead. [ChangeLog][QtCore] Added QDeadlineTimer, a counterpart to QElapsedTimer, used to mark a time point in the future (a deadline) and determine whether such a deadline has passed. Change-Id: Ifea6e497f11a461db432ffff144921f7fbc1d1d3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>