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

@ -344,6 +344,13 @@ typedef SDL_Window* SDL_WindowID;
#define SDL_RenderFill(X) (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()
#define SDL_KillThread(X)
/* The timeslice and timer resolution are no longer relevant */
#define SDL_TIMESLICE 10
#define TIMER_RESOLUTION 10
typedef Uint32 (SDLCALL * SDL_OldTimerCallback) (Uint32 interval);
extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback);
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
/*@}*//*Compatibility*/