summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qelapsedtimer_generic.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-08-06 16:27:18 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-09 03:26:29 +0200
commit6a8537356be5766fcdc5cf8fcb5fabb81abd09e7 (patch)
tree67c5e357d96c7d51d873f89bf017959ba326b3ab /src/corelib/tools/qelapsedtimer_generic.cpp
parent44e638f06965e1022a0da7a48105c83a6d373547 (diff)
Mark QElapsedTimer functions as Q_DECL_NOTHROW
All functions in QElapsedTimer are marked Q_DECL_NOTHROW. This code is often introduced in many places to deal with timeouts and doesn't need exception handlers. In particular, it's used in QMutex locking. In addition, mark QDateTime::currentMSecsSinceEpoch as nothrow, as it can't throw exceptions either and it is needed by the generic QElapsedTimer. Q{Date,Time}::current{Date,Time} operate on local time and run into at least one cancellation point, which we must consider throwing. And returning a QDateTime allocates memory. Change-Id: Id776c5ec831fc06d7419a9ff5442d9b35cff1a22 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qelapsedtimer_generic.cpp')
-rw-r--r--src/corelib/tools/qelapsedtimer_generic.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp
index a20b6b5662..fc53fd9b8a 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/tools/qelapsedtimer_generic.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\sa isMonotonic()
*/
-QElapsedTimer::ClockType QElapsedTimer::clockType()
+QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
return SystemTime;
}
@@ -61,7 +61,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType()
\sa clockType(), QElapsedTimer::ClockType
*/
-bool QElapsedTimer::isMonotonic()
+bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW
{
return false;
}
@@ -76,7 +76,7 @@ bool QElapsedTimer::isMonotonic()
\sa restart(), invalidate(), elapsed()
*/
-void QElapsedTimer::start()
+void QElapsedTimer::start() Q_DECL_NOTHROW
{
restart();
}
@@ -95,7 +95,7 @@ void QElapsedTimer::start()
\sa start(), invalidate(), elapsed()
*/
-qint64 QElapsedTimer::restart()
+qint64 QElapsedTimer::restart() Q_DECL_NOTHROW
{
qint64 old = t1;
t1 = QDateTime::currentMSecsSinceEpoch();
@@ -114,7 +114,7 @@ qint64 QElapsedTimer::restart()
\sa start(), restart(), hasExpired(), invalidate()
*/
-qint64 QElapsedTimer::nsecsElapsed() const
+qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW
{
return elapsed() * 1000000;
}
@@ -126,7 +126,7 @@ qint64 QElapsedTimer::nsecsElapsed() const
\sa start(), restart(), hasExpired(), invalidate()
*/
-qint64 QElapsedTimer::elapsed() const
+qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW
{
return QDateTime::currentMSecsSinceEpoch() - t1;
}
@@ -142,7 +142,7 @@ qint64 QElapsedTimer::elapsed() const
\sa clockType(), elapsed()
*/
-qint64 QElapsedTimer::msecsSinceReference() const
+qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW
{
return t1;
}
@@ -157,7 +157,7 @@ qint64 QElapsedTimer::msecsSinceReference() const
\sa secsTo(), elapsed()
*/
-qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
+qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
{
qint64 diff = other.t1 - t1;
return diff;
@@ -172,7 +172,7 @@ qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
\sa msecsTo(), elapsed()
*/
-qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const
+qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
{
return msecsTo(other) / 1000;
}
@@ -186,7 +186,7 @@ qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const
and the other isn't. However, two invalid timers are equal and thus this
function will return false.
*/
-bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2)
+bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
{
return v1.t1 < v2.t1;
}