summaryrefslogtreecommitdiffhomepage
path: root/compat/timer.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-06-10 12:50:25 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-06-10 12:50:25 +0200
commitd415d383db1e1cf8038ffb34459864e3b6e19f39 (patch)
tree888cfaaab4733269b4342ea0337460f774c87023 /compat/timer.hpp
parent1a4ad209341b7ef2364f7b6bc8195a4ac93838d0 (diff)
minor cleanup only
Diffstat (limited to 'compat/timer.hpp')
-rw-r--r--compat/timer.hpp16
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;