src/timer/SDL_timer.c
changeset 7139 dd722e7460c5
parent 6977 b73d51026c68
child 7191 75360622e65f
equal deleted inserted replaced
7138:52ba4fa156c7 7139:dd722e7460c5
    24 #include "SDL_timer_c.h"
    24 #include "SDL_timer_c.h"
    25 #include "SDL_atomic.h"
    25 #include "SDL_atomic.h"
    26 #include "SDL_cpuinfo.h"
    26 #include "SDL_cpuinfo.h"
    27 #include "SDL_thread.h"
    27 #include "SDL_thread.h"
    28 
    28 
       
    29 extern void SDL_StartTicks(void);
       
    30 
    29 /* #define DEBUG_TIMERS */
    31 /* #define DEBUG_TIMERS */
    30 
    32 
    31 typedef struct _SDL_Timer
    33 typedef struct _SDL_Timer
    32 {
    34 {
    33     int timerID;
    35     int timerID;
    68     SDL_Timer *timers;
    70     SDL_Timer *timers;
    69 } SDL_TimerData;
    71 } SDL_TimerData;
    70 
    72 
    71 static SDL_TimerData SDL_timer_data;
    73 static SDL_TimerData SDL_timer_data;
    72 
    74 
       
    75 static Uint32 ticks_started = 0;
       
    76 
       
    77 void
       
    78 SDL_InitTicks(void)
       
    79 {
       
    80     if (!ticks_started) {
       
    81         SDL_StartTicks();
       
    82         ticks_started = 1;
       
    83     }
       
    84 }
    73 
    85 
    74 /* The idea here is that any thread might add a timer, but a single
    86 /* The idea here is that any thread might add a timer, but a single
    75  * thread manages the active timer queue, sorted by scheduling time.
    87  * thread manages the active timer queue, sorted by scheduling time.
    76  *
    88  *
    77  * Timers are removed by simply setting a canceled flag
    89  * Timers are removed by simply setting a canceled flag