summaryrefslogtreecommitdiffhomepage
path: root/compat/timer.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-05-17 12:25:24 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-05-17 12:25:24 +0200
commite17cc16b100031672b3dbb0a4f74e198c20d091a (patch)
tree70dc5429a07367af117c45df4d129af8f2eb14a5 /compat/timer.hpp
parent5a8820764f3d539a4269d907e7977c45afe7bdab (diff)
compat/timer: use time_t
Diffstat (limited to 'compat/timer.hpp')
-rw-r--r--compat/timer.hpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/compat/timer.hpp b/compat/timer.hpp
index 3ceda093..b8b4ae59 100644
--- a/compat/timer.hpp
+++ b/compat/timer.hpp
@@ -12,16 +12,12 @@
#include "time.hpp"
#include <ctime>
+#include <type_traits>
-class OTR_COMPAT_EXPORT Timer final
+struct OTR_COMPAT_EXPORT Timer final
{
- struct timespec state;
- long long conv_nsecs(const struct timespec& cur) const;
-
- static void gettime(struct timespec* state);
+ using time_type = time_t;
- using ns = time_units::ns;
-public:
Timer();
void start();
@@ -32,21 +28,13 @@ public:
return time_cast<t>(ns(elapsed_nsecs()));
}
- template<typename t>
- bool is_elapsed(t&& time_value)
- {
- using namespace time_units;
-
- if (unlikely(elapsed<ns>() >= time_value))
- {
- start();
- return true;
- }
- return false;
- }
-
- long long elapsed_nsecs() const;
- double elapsed_usecs() const;
- double elapsed_ms() const;
- double elapsed_seconds() const;
+ time_type elapsed_nsecs() const;
+ time_type elapsed_usecs() const;
+ time_type elapsed_ms() const;
+ time_type elapsed_seconds() const;
+private:
+ struct timespec state;
+ static void gettime(struct timespec* state);
+ time_type conv_nsecs(const struct timespec& cur) const;
+ using ns = time_units::ns;
};