Improved timer implementation

The new timer model is formalized as using a separate thread to handle timer callbacks.  This was the case on almost every platform before, but it's now a requirement, and simplifies the implementation and makes it perform consistently across platforms.

Goals:
 * Minimize timer thread blocking
 * Dispatch timers as accurately as possible
 * SDL_AddTimer() and SDL_RemoveTimer() are completely threadsafe
 * SDL_RemoveTimer() doesn't crash with a timer that's expired or removed
This commit is contained in:
Sam Lantinga 2011-01-27 14:45:06 -08:00
parent 2fd57ffe61
commit dd4f2c1339
13 changed files with 379 additions and 833 deletions

View file

@ -27,21 +27,7 @@
#define ROUND_RESOLUTION(X) \
(((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
extern int SDL_timer_started;
extern int SDL_timer_running;
/* Data to handle a single periodic alarm */
extern Uint32 SDL_alarm_interval;
extern SDL_TimerCallback SDL_alarm_callback;
/* Set whether or not the timer should use a thread.
This should be called while the timer subsystem is running.
*/
extern int SDL_SetTimerThreaded(int value);
extern int SDL_TimerInit(void);
extern void SDL_TimerQuit(void);
/* This function is called from the SDL event thread if it is available */
extern void SDL_ThreadedTimerCheck(void);
/* vi: set ts=4 sw=4 expandtab: */