author | Gerald Squelart <gsquelart@mozilla.com> |
Fri, 21 Aug 2015 05:36:00 -0400 | |
changeset 258973 | 332b56e301156802f269ded2a557f50b762b3ef2 |
parent 258972 | d9ac2969f3bb3fbd14d56a32c05bdf853b92ec9b |
child 258974 | 2d2b71f2c970ca20bb2ea65f0c919b347db6864e |
push id | 29268 |
push user | ryanvm@gmail.com |
push date | Tue, 25 Aug 2015 00:37:23 +0000 |
treeherder | mozilla-central@08015770c9d6 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nfroyd |
bugs | 1197145 |
milestone | 43.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mozglue/misc/TimeStamp.h +++ b/mozglue/misc/TimeStamp.h @@ -253,16 +253,24 @@ public: { return mValue == aOther.mValue; } template<typename E> bool operator!=(const BaseTimeDuration<E>& aOther) const { return mValue != aOther.mValue; } + bool IsZero() const + { + return mValue == 0; + } + explicit operator bool() const + { + return mValue != 0; + } // Return a best guess at the system's current timing resolution, // which might be variable. BaseTimeDurations below this order of // magnitude are meaningless, and those at the same order of // magnitude or just above are suspect. static BaseTimeDuration Resolution() { return FromTicks(BaseTimeDurationPlatformUtils::ResolutionInTicks()); } @@ -409,16 +417,25 @@ public: #endif /** * Return true if this is the "null" moment */ bool IsNull() const { return mValue == 0; } /** + * Return true if this is not the "null" moment, may be used in tests, e.g.: + * |if (timestamp) { ... }| + */ + explicit operator bool() const + { + return mValue != 0; + } + + /** * Return a timestamp reflecting the current elapsed system time. This * is monotonically increasing (i.e., does not decrease) over the * lifetime of this process' XPCOM session. * * Now() is trying to ensure the best possible precision on each platform, * at least one millisecond. * * NowLoRes() has been introduced to workaround performance problems of