Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Time Class Reference

#include <TimeIncludes.h>

Static Public Member Functions

static DLLEXPORT int64_t GetTimeMs64 ()
 
static DLLEXPORT int64_t GetTimeMicro64 ()
 
static DLLEXPORT WantedClockType::time_point GetThreadSafeSteadyTimePoint ()
 

Detailed Description

Definition at line 22 of file TimeIncludes.h.

Member Function Documentation

◆ GetThreadSafeSteadyTimePoint()

DLLEXPORT WantedClockType::time_point Time::GetThreadSafeSteadyTimePoint ( )
static
Note
This should be not required when using the standard

Definition at line 83 of file TimeIncludes.cpp.

84 {
85 
86  return WantedClockType::now();
87 }

◆ GetTimeMicro64()

int64_t Time::GetTimeMicro64 ( )
static

Definition at line 48 of file TimeIncludes.cpp.

49 {
50 #ifdef _WIN32
51  /* Windows */
52  FILETIME ft;
53  LARGE_INTEGER li;
54 
55  /* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and
56  * copy it to a LARGE_INTEGER structure. */
57  GetSystemTimeAsFileTime(&ft);
58  li.LowPart = ft.dwLowDateTime;
59  li.HighPart = ft.dwHighDateTime;
60 
61  int64_t ret = li.QuadPart;
62  ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */
63  ret /= 10; /* From 100 nano seconds (10^-7) to 1 microsecond (10^-6) intervals */
64 
65  return ret;
66 #elif defined __linux__
67  /* Linux */
68  struct timeval tv;
69 
70  gettimeofday(&tv, NULL);
71 
72  int64_t ret = tv.tv_usec;
73 
74  /* Adds the seconds (10^0) after converting them to microseconds (10^-6) */
75  ret += (tv.tv_sec * 1000000);
76 
77  return ret;
78 #else
79 #error no working get time on platform
80 #endif
81 }

◆ GetTimeMs64()

int64_t Time::GetTimeMs64 ( )
static

Definition at line 11 of file TimeIncludes.cpp.

12 {
13 #ifdef _WIN32
14  /* Windows */
15  FILETIME ft;
16  LARGE_INTEGER li;
17 
18  /* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and
19  * copy it to a LARGE_INTEGER structure. */
20  GetSystemTimeAsFileTime(&ft);
21  li.LowPart = ft.dwLowDateTime;
22  li.HighPart = ft.dwHighDateTime;
23 
24  int64_t ret = li.QuadPart;
25  ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */
26  ret /= 10000; /* From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals */
27 
28  return ret;
29 #elif defined __linux__
30  /* Linux */
31  struct timeval tv;
32 
33  gettimeofday(&tv, NULL);
34 
35  int64_t ret = tv.tv_usec;
36  /* Convert from micro seconds (10^-6) to milliseconds (10^-3) */
37  ret /= 1000;
38 
39  /* Adds the seconds (10^0) after converting them to milliseconds (10^-3) */
40  ret += (tv.tv_sec * 1000);
41 
42  return ret;
43 #else
44 #error no working get time on platform
45 #endif
46 }

The documentation for this class was generated from the following files: