|
|
@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
|
|
|
|
|
|
|
|
class plTimerShare |
|
|
|
class plTimerShare |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
private: |
|
|
|
typedef std::chrono::high_resolution_clock Clock; |
|
|
|
typedef std::chrono::high_resolution_clock Clock; |
|
|
|
typedef std::chrono::time_point<Clock> TimePoint; |
|
|
|
typedef std::chrono::time_point<Clock> TimePoint; |
|
|
|
typedef Clock::duration Duration; |
|
|
|
typedef Clock::duration Duration; |
|
|
@ -72,8 +73,39 @@ protected: |
|
|
|
bool fClamping; |
|
|
|
bool fClamping; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double GetSeconds() const; |
|
|
|
template<typename T = double> |
|
|
|
double GetMilliSeconds() const; |
|
|
|
T GetSeconds() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
typedef std::chrono::duration<T> duration_type; |
|
|
|
|
|
|
|
Duration d = GetRawTicks(); |
|
|
|
|
|
|
|
return std::chrono::duration_cast<duration_type>(d).count(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T = double> |
|
|
|
|
|
|
|
T GetSeconds(uint64_t ticks) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
typedef std::chrono::duration<T> duration_type; |
|
|
|
|
|
|
|
Duration d(ticks); |
|
|
|
|
|
|
|
return std::chrono::duration_cast<duration_type>(d).count(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T = double> |
|
|
|
|
|
|
|
T GetMilliSeconds() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
typedef std::chrono::duration<T, std::milli> duration_type; |
|
|
|
|
|
|
|
Duration d = GetRawTicks(); |
|
|
|
|
|
|
|
return std::chrono::duration_cast<duration_type>(d).count(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T = double> |
|
|
|
|
|
|
|
T GetMilliSeconds(uint64_t ticks) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
typedef std::chrono::duration<T, std::milli> duration_type; |
|
|
|
|
|
|
|
Duration d(ticks); |
|
|
|
|
|
|
|
return std::chrono::duration_cast<duration_type>(d).count(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t GetTicks() const; |
|
|
|
|
|
|
|
|
|
|
|
float GetDelSysSeconds() const { return fDelSysSeconds; } |
|
|
|
float GetDelSysSeconds() const { return fDelSysSeconds; } |
|
|
|
double GetSysSeconds() const { return fSysSeconds; } |
|
|
|
double GetSysSeconds() const { return fSysSeconds; } |
|
|
@ -112,8 +144,19 @@ protected: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
static double GetSeconds() { return fTimer->GetSeconds(); } |
|
|
|
template<typename T = double> |
|
|
|
static double GetMilliSeconds() { return fTimer->GetMilliSeconds(); } |
|
|
|
static T GetSeconds() { return fTimer->GetSeconds<T>(); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T = double> |
|
|
|
|
|
|
|
static T GetSeconds(uint64_t ticks) { return fTimer->GetSeconds<T>(ticks); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T = double> |
|
|
|
|
|
|
|
static T GetMilliSeconds() { return fTimer->GetMilliSeconds<T>(); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T = double> |
|
|
|
|
|
|
|
static T GetMilliSeconds(uint64_t ticks) { return fTimer->GetMilliSeconds<T>(ticks); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static uint64_t GetTicks() { return fTimer->GetTicks(); } |
|
|
|
|
|
|
|
|
|
|
|
static float GetDelSysSeconds() { return fTimer->GetDelSysSeconds(); } |
|
|
|
static float GetDelSysSeconds() { return fTimer->GetDelSysSeconds(); } |
|
|
|
static double GetSysSeconds() { return fTimer->GetSysSeconds(); } |
|
|
|
static double GetSysSeconds() { return fTimer->GetSysSeconds(); } |
|
|
@ -133,18 +176,6 @@ public: |
|
|
|
static float GetTimeClamp() { return fTimer->GetTimeClamp(); } |
|
|
|
static float GetTimeClamp() { return fTimer->GetTimeClamp(); } |
|
|
|
static bool IsClamping() { return fTimer->IsClamping(); } |
|
|
|
static bool IsClamping() { return fTimer->IsClamping(); } |
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////
|
|
|
|
|
|
|
|
// Precision timer routines - these are stateless and implemented as statics.
|
|
|
|
|
|
|
|
///////////////////////////
|
|
|
|
|
|
|
|
static uint32_t GetPrecTickCount(); |
|
|
|
|
|
|
|
static double GetPrecTicksPerSec(); |
|
|
|
|
|
|
|
static double PrecTicksToSecs(uint32_t ticks); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If you need to time something longer than 20 seconds, use this instead of
|
|
|
|
|
|
|
|
// the precision timer. It works the same, it just gives you full resolution.
|
|
|
|
|
|
|
|
static uint64_t GetFullTickCount(); |
|
|
|
|
|
|
|
static float FullTicksToMs(uint64_t ticks); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Pass GetTheTimer() into other process space, and then call SetTheTimer() on it.
|
|
|
|
// Pass GetTheTimer() into other process space, and then call SetTheTimer() on it.
|
|
|
|
static void SetTheTimer(plTimerShare* timer); |
|
|
|
static void SetTheTimer(plTimerShare* timer); |
|
|
|