diff src/timer/dummy/SDL_systimer.c @ 5113:481dabb098ef

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
author Sam Lantinga <slouken@libsdl.org>
date Thu, 27 Jan 2011 14:45:06 -0800
parents f7b03b6838cb
children b530ef003506
line wrap: on
line diff
--- a/src/timer/dummy/SDL_systimer.c	Thu Jan 27 10:40:17 2011 -0800
+++ b/src/timer/dummy/SDL_systimer.c	Thu Jan 27 14:45:06 2011 -0800
@@ -24,7 +24,6 @@
 #if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
 
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
 
 void
 SDL_StartTicks(void)
@@ -44,57 +43,6 @@
     SDL_Unsupported();
 }
 
-#include "SDL_thread.h"
-
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static SDL_Thread *timer = NULL;
-
-static int
-RunTimer(void *unused)
-{
-    while (timer_alive) {
-        if (SDL_timer_running) {
-            SDL_ThreadedTimerCheck();
-        }
-        SDL_Delay(1);
-    }
-    return (0);
-}
+#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
 
-/* This is only called if the event thread is not running */
-int
-SDL_SYS_TimerInit(void)
-{
-    timer_alive = 1;
-    timer = SDL_CreateThread(RunTimer, NULL);
-    if (timer == NULL)
-        return (-1);
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    timer_alive = 0;
-    if (timer) {
-        SDL_WaitThread(timer, NULL);
-        timer = NULL;
-    }
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: threaded timer in use");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
 /* vi: set ts=4 sw=4 expandtab: */