diff options
Diffstat (limited to 'compat/timer.hpp')
-rw-r--r-- | compat/timer.hpp | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/compat/timer.hpp b/compat/timer.hpp index 03b537ac..47072226 100644 --- a/compat/timer.hpp +++ b/compat/timer.hpp @@ -10,43 +10,19 @@ #include "export.hpp" #include "time.hpp" - #include <ctime> -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 ns = time_units::ns; -public: Timer(); void start(); - template<typename t> - t elapsed() const - { - using namespace time_units; - 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; - double elapsed_usecs() const; double elapsed_ms() const; double elapsed_seconds() const; + +private: + struct timespec state {}; + static void gettime(struct timespec* state); + struct timespec get_delta() const; + using ns = time_units::ns; }; |