Mercurial > sdl-ios-xcode
diff src/events/SDL_events.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 | c2539ff054c8 |
children | dc0dfdd58f27 |
line wrap: on
line diff
--- a/src/events/SDL_events.c Thu Jan 27 10:40:17 2011 -0800 +++ b/src/events/SDL_events.c Thu Jan 27 14:45:06 2011 -0800 @@ -123,9 +123,6 @@ /* Give up the CPU for the rest of our timeslice */ SDL_EventLock.safe = 1; - if (SDL_timer_running) { - SDL_ThreadedTimerCheck(); - } SDL_Delay(1); /* Check for event locking. @@ -140,7 +137,6 @@ SDL_EventLock.safe = 0; SDL_mutexV(SDL_EventLock.lock); } - SDL_SetTimerThreaded(0); event_thread = 0; return (0); } @@ -168,8 +164,6 @@ } SDL_EventLock.safe = 0; - /* The event thread will handle timers too */ - SDL_SetTimerThreaded(2); #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) #undef SDL_CreateThread SDL_EventThread =