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 20 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 82 of file TimeIncludes.cpp.

82  {
83 
84  return WantedClockType::now();
85 }

◆ GetTimeMicro64()

int64_t Time::GetTimeMicro64 ( )
static

Definition at line 48 of file TimeIncludes.cpp.

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

◆ GetTimeMs64()

int64_t Time::GetTimeMs64 ( )
static

Definition at line 12 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 copy it
19  * 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: