diff options
Diffstat (limited to 'indra/llcommon/lltimer.cpp')
-rwxr-xr-x | indra/llcommon/lltimer.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 9ebc6de7f4..74f3a7f587 100755 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -31,11 +31,9 @@ #include "u64.h" #if LL_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include <winsock2.h> -# include <windows.h> +# include "llwin32headerslean.h" #elif LL_LINUX || LL_SOLARIS || LL_DARWIN -# include <errno.h> +# include <errno.h> # include <sys/time.h> #else # error "architecture not supported" @@ -45,7 +43,6 @@ // // Locally used constants // -const U32 SEC_PER_DAY = 86400; const F64 SEC_TO_MICROSEC = 1000000.f; const U64 SEC_TO_MICROSEC_U64 = 1000000; const F64 USEC_TO_SEC_F64 = 0.000001; @@ -228,7 +225,7 @@ void update_clock_frequencies() // returns a U64 number that represents the number of // microseconds since the unix epoch - Jan 1, 1970 -U64 totalTime() +LLUnitImplicit<U64, LLUnits::Microseconds> totalTime() { U64 current_clock_count = get_clock_count(); if (!gTotalTimeClockCount) @@ -265,7 +262,7 @@ U64 totalTime() } // Return the total clock tick count in microseconds. - return (U64)(gTotalTimeClockCount*gClocksToMicroseconds); + return U64Microseconds(gTotalTimeClockCount*gClocksToMicroseconds); } @@ -283,18 +280,29 @@ LLTimer::LLTimer() } LLTimer::~LLTimer() +{} + +// static +void LLTimer::initClass() +{ + if (!sTimer) sTimer = new LLTimer; +} + +// static +void LLTimer::cleanupClass() { + delete sTimer; sTimer = NULL; } // static -U64 LLTimer::getTotalTime() +LLUnitImplicit<U64, LLUnits::Microseconds> LLTimer::getTotalTime() { // simply call into the implementation function. return totalTime(); } // static -F64 LLTimer::getTotalSeconds() +LLUnitImplicit<F64, LLUnits::Seconds> LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -343,36 +351,36 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -F64 LLTimer::getElapsedTimeF64() const +LLUnitImplicit<F64, LLUnits::Seconds> LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeF32() const +LLUnitImplicit<F32, LLUnits::Seconds> LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -F64 LLTimer::getElapsedTimeAndResetF64() +LLUnitImplicit<F64, LLUnits::Seconds> LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeAndResetF32() +LLUnitImplicit<F32, LLUnits::Seconds> LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } /////////////////////////////////////////////////////////////////////////////// -void LLTimer::setTimerExpirySec(F32 expiration) +void LLTimer::setTimerExpirySec(LLUnitImplicit<F32, LLUnits::Seconds> expiration) { mExpirationTicks = get_clock_count() + (U64)((F32)(expiration * gClockFrequency)); } -F32 LLTimer::getRemainingTimeF32() const +LLUnitImplicit<F32, LLUnits::Seconds> LLTimer::getRemainingTimeF32() const { U64 cur_ticks = get_clock_count(); if (cur_ticks > mExpirationTicks) @@ -448,7 +456,7 @@ BOOL LLTimer::knownBadTimer() { if (!wcscmp(pci_id, bad_pci_list[check])) { -// llwarns << "unreliable PCI chipset found!! " << pci_id << endl; +// LL_WARNS() << "unreliable PCI chipset found!! " << pci_id << endl; failed = TRUE; break; } |