Wrap hiResCounterHandler in a function to prevent an order of initialization problems

This commit is contained in:
Patrick Dehne
2013-10-20 23:38:52 +02:00
parent 30cf0f8d3a
commit 504a892887

View File

@@ -267,11 +267,15 @@ private:
double highResTimerToMillisecRatio; double highResTimerToMillisecRatio;
}; };
static HiResCounterHandler hiResCounterHandler; static HiResCounterHandler& hiResCounterHandler()
{
static HiResCounterHandler hiResCounterHandler;
return hiResCounterHandler;
}
uint32 beast_millisecondsSinceStartup() noexcept { return hiResCounterHandler.millisecondsSinceStartup(); } uint32 beast_millisecondsSinceStartup() noexcept { return hiResCounterHandler().millisecondsSinceStartup(); }
double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHandler.getMillisecondCounterHiRes(); } double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHandler().getMillisecondCounterHiRes(); }
int64 Time::getHighResolutionTicksPerSecond() noexcept { return hiResCounterHandler.highResTimerFrequency; } int64 Time::getHighResolutionTicksPerSecond() noexcept { return hiResCounterHandler().highResTimerFrequency; }
int64 Time::getHighResolutionTicks() noexcept { return (int64) mach_absolute_time(); } int64 Time::getHighResolutionTicks() noexcept { return (int64) mach_absolute_time(); }
bool Time::setSystemTimeToThisTime() const bool Time::setSystemTimeToThisTime() const