simplify RageZeroTimer

avoid starting the SDL timer system; it starts a thread
This commit is contained in:
Glenn Maynard
2004-03-13 23:11:08 +00:00
parent 02d8bc45e8
commit c2fa441b7e
2 changed files with 10 additions and 8 deletions
+8 -3
View File
@@ -9,7 +9,7 @@
/* We only actually get 1000 using SDL. */ /* We only actually get 1000 using SDL. */
#define TIMESTAMP_RESOLUTION 1000000 #define TIMESTAMP_RESOLUTION 1000000
const RageZeroTimer_t RageZeroTimer; const RageTimer RageZeroTimer(0,0);
void mySDL_GetTicks( unsigned &secs, unsigned &us ) void mySDL_GetTicks( unsigned &secs, unsigned &us )
{ {
@@ -17,8 +17,13 @@ void mySDL_GetTicks( unsigned &secs, unsigned &us )
if( !bInitialized ) if( !bInitialized )
{ {
bInitialized = true; bInitialized = true;
if( !SDL_WasInit(SDL_INIT_TIMER) ) /* We don't want the timer system; it starts a thread, and we never use it. */
SDL_InitSubSystem( SDL_INIT_TIMER ); // if( !SDL_WasInit(SDL_INIT_TIMER) )
// SDL_InitSubSystem( SDL_INIT_TIMER );
/* Calling this will still initialize the hidden "ticks" system, so we can
* use SDL_GetTicks. */
SDL_InitSubSystem( 0 );
} }
/* Ticks may be less than last for at least two reasons: the time may have wrapped (after /* Ticks may be less than last for at least two reasons: the time may have wrapped (after
+2 -5
View File
@@ -27,6 +27,7 @@ class RageTimer
{ {
public: public:
RageTimer() { Touch(); } RageTimer() { Touch(); }
RageTimer( int secs, int us ): m_secs(secs), m_us(us) { }
/* Time ago this RageTimer represents. */ /* Time ago this RageTimer represents. */
float Ago() const; float Ago() const;
@@ -62,11 +63,7 @@ private:
static float Difference(const RageTimer &lhs, const RageTimer &rhs); static float Difference(const RageTimer &lhs, const RageTimer &rhs);
}; };
struct RageZeroTimer_t: public RageTimer extern const RageTimer RageZeroTimer;
{
RageZeroTimer_t() { SetZero(); }
};
extern const RageZeroTimer_t RageZeroTimer;
#endif #endif