summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qelapsedtimer_unix.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_unix.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_unix.cpp')
-rw-r--r--src/corelib/tools/qelapsedtimer_unix.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp
index 36acc81735..f2e43c282b 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/tools/qelapsedtimer_unix.cpp
@@ -102,13 +102,13 @@ static inline qint64 fractionAdjustment()
}
}
-bool QElapsedTimer::isMonotonic()
+bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW
{
unixCheckClockType();
return monotonicClockAvailable;
}
-QElapsedTimer::ClockType QElapsedTimer::clockType()
+QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
unixCheckClockType();
return monotonicClockAvailable ? MonotonicClock : SystemTime;
@@ -134,7 +134,7 @@ static inline void do_gettime(qint64 *sec, qint64 *frac)
}
// used in qcore_unix.cpp and qeventdispatcher_unix.cpp
-timeval qt_gettime()
+timeval qt_gettime() Q_DECL_NOTHROW
{
qint64 sec, frac;
do_gettime(&sec, &frac);
@@ -157,17 +157,17 @@ static qint64 elapsedAndRestart(qint64 sec, qint64 frac,
return sec * Q_INT64_C(1000) + frac / fractionAdjustment();
}
-void QElapsedTimer::start()
+void QElapsedTimer::start() Q_DECL_NOTHROW
{
do_gettime(&t1, &t2);
}
-qint64 QElapsedTimer::restart()
+qint64 QElapsedTimer::restart() Q_DECL_NOTHROW
{
return elapsedAndRestart(t1, t2, &t1, &t2);
}
-qint64 QElapsedTimer::nsecsElapsed() const
+qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW
{
qint64 sec, frac;
do_gettime(&sec, &frac);
@@ -178,30 +178,30 @@ qint64 QElapsedTimer::nsecsElapsed() const
return sec * Q_INT64_C(1000000000) + frac;
}
-qint64 QElapsedTimer::elapsed() const
+qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW
{
qint64 sec, frac;
return elapsedAndRestart(t1, t2, &sec, &frac);
}
-qint64 QElapsedTimer::msecsSinceReference() const
+qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW
{
return t1 * Q_INT64_C(1000) + t2 / fractionAdjustment();
}
-qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
+qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
{
qint64 secs = other.t1 - t1;
qint64 fraction = other.t2 - t2;
return secs * Q_INT64_C(1000) + fraction / fractionAdjustment();
}
-qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const
+qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
{
return other.t1 - t1;
}
-bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2)
+bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
{
return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2);
}