diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-06-10 12:50:25 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-06-10 12:50:25 +0200 |
commit | d415d383db1e1cf8038ffb34459864e3b6e19f39 (patch) | |
tree | 888cfaaab4733269b4342ea0337460f774c87023 /compat/timer.hpp | |
parent | 1a4ad209341b7ef2364f7b6bc8195a4ac93838d0 (diff) |
minor cleanup only
Diffstat (limited to 'compat/timer.hpp')
-rw-r--r-- | compat/timer.hpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compat/timer.hpp b/compat/timer.hpp index 6af7430d..ac255a9d 100644 --- a/compat/timer.hpp +++ b/compat/timer.hpp @@ -20,6 +20,7 @@ #include <ctime> #include "time.hpp" +#include "util.hpp" class OTR_COMPAT_EXPORT Timer final { @@ -43,7 +44,20 @@ public: t elapsed() const { using namespace time_units; - return static_cast<const t&>(ns(elapsed_nsecs())); + return time_cast<t>(ns(elapsed_nsecs())); + } + + template<typename t> + bool is_elapsed(const t& time_value) + { + using namespace time_units; + + if (unlikely(elapsed<ns>() >= time_value)) + { + start(); + return true; + } + return false; } long long elapsed_nsecs() const; |