feat(Core/Time): remove inherited ACE Time (#3455)

Co-authored-by: Viste <viste02@gmail.com>
This commit is contained in:
Kargatum
2020-09-11 19:03:26 +07:00
committed by GitHub
parent 8b3621779e
commit e15a493927
20 changed files with 157 additions and 58 deletions

View File

@@ -7,13 +7,23 @@
#ifndef ACORE_TIMER_H
#define ACORE_TIMER_H
#include "ace/OS_NS_sys_time.h"
#include "Common.h"
#include "Duration.h"
inline TimePoint GetApplicationStartTime()
{
using namespace std::chrono;
static const steady_clock::time_point ApplicationStartTime = steady_clock::now();
return ApplicationStartTime;
}
inline uint32 getMSTime()
{
static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday();
return (ACE_OS::gettimeofday() - ApplicationStartTime).msec();
using namespace std::chrono;
return uint32(duration_cast<milliseconds>(steady_clock::now() - GetApplicationStartTime()).count());
}
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
@@ -25,6 +35,14 @@ inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
return newMSTime - oldMSTime;
}
inline uint32 getMSTimeDiff(uint32 oldMSTime, TimePoint 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());