diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-07-16 18:53:56 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-07-16 18:53:56 -0700 |
commit | 4ea281c750c5afcc68f2832bb42d98a1cbce6735 (patch) | |
tree | 60bc7d3ccba2c54859e2e023997cc027cc67aea7 /include/mbgl/util/time.hpp | |
parent | c1a64dc5fa73b54cc5de77629781dfc74302a1e7 (diff) | |
download | qtlocation-mapboxgl-4ea281c750c5afcc68f2832bb42d98a1cbce6735.tar.gz |
rename llmr => mbgl
Diffstat (limited to 'include/mbgl/util/time.hpp')
-rw-r--r-- | include/mbgl/util/time.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/include/mbgl/util/time.hpp b/include/mbgl/util/time.hpp new file mode 100644 index 0000000000..eacee2c982 --- /dev/null +++ b/include/mbgl/util/time.hpp @@ -0,0 +1,42 @@ +#ifndef MBGL_UTIL_TIME +#define MBGL_UTIL_TIME + +#include <uv.h> + +namespace mbgl { + +typedef uint64_t timestamp; + +namespace util { + + +// Returns time in nanoseconds since an arbitrary point in the past. This has +// no relation to the current time, but is continuously increasing, so +// comparisons between different timestamps produce meaningful values. +inline timestamp now() { + return uv_hrtime(); +} +} + +// used for time conversions +constexpr timestamp operator"" _nanoseconds (long double ns) { return ns; } +constexpr timestamp operator"" _nanosecond (long double ns) { return ns; } +constexpr timestamp operator"" _microseconds (long double us) { return us * 1e3; } +constexpr timestamp operator"" _microsecond (long double us) { return us * 1e3; } +constexpr timestamp operator"" _milliseconds (long double ms) { return ms * 1e6; } +constexpr timestamp operator"" _millisecond (long double ms) { return ms * 1e6; } +constexpr timestamp operator"" _seconds (long double s) { return s * 1e9; } +constexpr timestamp operator"" _second (long double s) { return s * 1e9; } + +constexpr timestamp operator"" _nanoseconds (unsigned long long ns) { return ns; } +constexpr timestamp operator"" _nanosecond (unsigned long long ns) { return ns; } +constexpr timestamp operator"" _microseconds (unsigned long long us) { return us * 1e3; } +constexpr timestamp operator"" _microsecond (unsigned long long us) { return us * 1e3; } +constexpr timestamp operator"" _milliseconds (unsigned long long ms) { return ms * 1e6; } +constexpr timestamp operator"" _millisecond (unsigned long long ms) { return ms * 1e6; } +constexpr timestamp operator"" _seconds (unsigned long long s) { return s * 1e9; } +constexpr timestamp operator"" _second (unsigned long long s) { return s * 1e9; } + +} + +#endif |