summaryrefslogtreecommitdiff
path: root/indra/llcommon/lltimer.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/lltimer.h')
-rwxr-xr-xindra/llcommon/lltimer.h63
1 files changed, 38 insertions, 25 deletions
diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h
index e73741217c..ec70213447 100755
--- a/indra/llcommon/lltimer.h
+++ b/indra/llcommon/lltimer.h
@@ -37,6 +37,7 @@
#include <string>
#include <list>
// units conversions
+#include "llunits.h"
#ifndef USEC_PER_SEC
const U32 USEC_PER_SEC = 1000000;
#endif
@@ -55,27 +56,34 @@ public:
protected:
U64 mLastClockCount;
U64 mExpirationTicks;
- BOOL mStarted;
+ bool mStarted;
public:
LLTimer();
~LLTimer();
- static void initClass() { if (!sTimer) sTimer = new LLTimer; }
- static void cleanupClass() { delete sTimer; sTimer = NULL; }
+ static void initClass();
+ static void cleanupClass();
// Return a high precision number of seconds since the start of
// this application instance.
- static F64 getElapsedSeconds()
+ static F64SecondsImplicit getElapsedSeconds()
+ {
+ if (sTimer)
{
return sTimer->getElapsedTimeF64();
}
+ else
+ {
+ return 0;
+ }
+ }
// Return a high precision usec since epoch
- static U64 getTotalTime();
+ static U64MicrosecondsImplicit getTotalTime();
// Return a high precision seconds since epoch
- static F64 getTotalSeconds();
+ static F64SecondsImplicit getTotalSeconds();
// MANIPULATORS
@@ -83,21 +91,21 @@ public:
void stop() { mStarted = FALSE; }
void reset(); // Resets the timer
void setLastClockCount(U64 current_count); // Sets the timer so that the next elapsed call will be relative to this time
- void setTimerExpirySec(F32 expiration);
+ void setTimerExpirySec(F32SecondsImplicit expiration);
BOOL checkExpirationAndReset(F32 expiration);
BOOL hasExpired() const;
- F32 getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset
- F64 getElapsedTimeAndResetF64();
+ F32SecondsImplicit getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset
+ F64SecondsImplicit getElapsedTimeAndResetF64();
- F32 getRemainingTimeF32() const;
+ F32SecondsImplicit getRemainingTimeF32() const;
static BOOL knownBadTimer();
// ACCESSORS
- F32 getElapsedTimeF32() const; // Returns elapsed time in seconds
- F64 getElapsedTimeF64() const; // Returns elapsed time in seconds
+ F32SecondsImplicit getElapsedTimeF32() const; // Returns elapsed time in seconds
+ F64SecondsImplicit getElapsedTimeF64() const; // Returns elapsed time in seconds
- BOOL getStarted() const { return mStarted; }
+ bool getStarted() const { return mStarted; }
static U64 getCurrentClockCount(); // Returns the raw clockticks
@@ -106,9 +114,21 @@ public:
//
// Various functions for initializing/accessing clock and timing stuff. Don't use these without REALLY knowing how they work.
//
+struct TimerInfo
+{
+ TimerInfo();
+ void update();
+
+ F64HertzImplicit mClockFrequency;
+ F64SecondsImplicit mClockFrequencyInv;
+ F64MicrosecondsImplicit mClocksToMicroseconds;
+ U64 mTotalTimeClockCount;
+ U64 mLastTotalTimeClockCount;
+};
+
+TimerInfo& get_timer_info();
+
LL_COMMON_API U64 get_clock_count();
-LL_COMMON_API F64 calc_clock_frequency(U32 msecs);
-LL_COMMON_API void update_clock_frequencies();
// Sleep for milliseconds
LL_COMMON_API void ms_sleep(U32 ms);
@@ -146,13 +166,6 @@ static inline time_t time_max()
}
}
-// These are really statics but they've been global for awhile
-// and they're material to other timing classes. If you are
-// not implementing a timer class, do not use these directly.
-extern LL_COMMON_API F64 gClockFrequency;
-extern LL_COMMON_API F64 gClockFrequencyInv;
-extern LL_COMMON_API F64 gClocksToMicroseconds;
-
// Correction factor used by time_corrected() above.
extern LL_COMMON_API S32 gUTCOffset;
@@ -167,9 +180,9 @@ LL_COMMON_API BOOL is_daylight_savings();
// struct tm* internal_time = utc_to_pacific_time(utc_time, gDaylight);
LL_COMMON_API struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time);
-LL_COMMON_API void microsecondsToTimecodeString(U64 current_time, std::string& tcstring);
-LL_COMMON_API void secondsToTimecodeString(F32 current_time, std::string& tcstring);
+LL_COMMON_API void microsecondsToTimecodeString(U64MicrosecondsImplicit current_time, std::string& tcstring);
+LL_COMMON_API void secondsToTimecodeString(F32SecondsImplicit current_time, std::string& tcstring);
-U64 LL_COMMON_API totalTime(); // Returns current system time in microseconds
+U64MicrosecondsImplicit LL_COMMON_API totalTime(); // Returns current system time in microseconds
#endif