aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Timer.h
diff options
context:
space:
mode:
authorChaouki Dhib <chaodhib@gmail.com>2019-04-15 23:31:25 +0200
committerGitHub <noreply@github.com>2019-04-15 23:31:25 +0200
commit975f1e364a6a68be2beca261a64ea8aecc16f6f6 (patch)
treeb1f27c7cd32542a7503fcb9f173fee9131d8ad7d /src/common/Utilities/Timer.h
parent9f32aaf4548b4bcb429d78a72f74521465efc8a7 (diff)
Core/Movement: Add time synchronisation (#18189)
Diffstat (limited to 'src/common/Utilities/Timer.h')
-rw-r--r--src/common/Utilities/Timer.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/common/Utilities/Timer.h b/src/common/Utilities/Timer.h
index be0f28a95ee..11f9cb2accc 100644
--- a/src/common/Utilities/Timer.h
+++ b/src/common/Utilities/Timer.h
@@ -22,13 +22,20 @@
#include "Define.h"
#include <chrono>
-inline uint32 getMSTime()
+inline std::chrono::steady_clock::time_point GetApplicationStartTime()
{
using namespace std::chrono;
static const steady_clock::time_point ApplicationStartTime = steady_clock::now();
- return uint32(duration_cast<milliseconds>(steady_clock::now() - ApplicationStartTime).count());
+ return ApplicationStartTime;
+}
+
+inline uint32 getMSTime()
+{
+ using namespace std::chrono;
+
+ return uint32(duration_cast<milliseconds>(steady_clock::now() - GetApplicationStartTime()).count());
}
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
@@ -40,6 +47,14 @@ inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
return newMSTime - oldMSTime;
}
+inline uint32 getMSTimeDiff(uint32 oldMSTime, std::chrono::steady_clock::time_point newTime)
+{
+ using namespace std::chrono;
+
+ uint32 newMSTime = uint32(duration_cast<milliseconds>(newTime - GetApplicationStartTime()).count());
+ return getMSTimeDiff(oldMSTime, newMSTime);
+}
+
inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
{
return getMSTimeDiff(oldMSTime, getMSTime());