Mercurial > sdl-ios-xcode
comparison src/events/SDL_events.c @ 1028:5ba65305c954
Fix various problems with the timer code.
* SDL_timer_running wasn't always updated correctly.
* Fixed occasional crash in SDL_SetTimer() when clearing threaded timers
* It was possible to get both the timer thread and event thread running
* Other misc. cleanup
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 13 Jan 2005 23:24:56 +0000 |
parents | b8d311d90021 |
children | 28ac87a38c17 |
comparison
equal
deleted
inserted
replaced
1027:c69697a85412 | 1028:5ba65305c954 |
---|---|
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 static int SDL_GobbleEvents(void *unused) | 92 static int SDL_GobbleEvents(void *unused) |
93 { | 93 { |
94 SDL_SetTimerThreaded(2); | |
95 event_thread = SDL_ThreadID(); | 94 event_thread = SDL_ThreadID(); |
96 while ( SDL_EventQ.active ) { | 95 while ( SDL_EventQ.active ) { |
97 SDL_VideoDevice *video = current_video; | 96 SDL_VideoDevice *video = current_video; |
98 SDL_VideoDevice *this = current_video; | 97 SDL_VideoDevice *this = current_video; |
99 | 98 |
112 } | 111 } |
113 #endif | 112 #endif |
114 | 113 |
115 /* Give up the CPU for the rest of our timeslice */ | 114 /* Give up the CPU for the rest of our timeslice */ |
116 SDL_EventLock.safe = 1; | 115 SDL_EventLock.safe = 1; |
117 if( SDL_timer_running ) { | 116 if ( SDL_timer_running ) { |
118 SDL_ThreadedTimerCheck(); | 117 SDL_ThreadedTimerCheck(); |
119 } | 118 } |
120 SDL_Delay(1); | 119 SDL_Delay(1); |
121 | 120 |
122 /* Check for event locking. | 121 /* Check for event locking. |
160 if ( SDL_EventLock.lock == NULL ) { | 159 if ( SDL_EventLock.lock == NULL ) { |
161 return(-1); | 160 return(-1); |
162 } | 161 } |
163 SDL_EventLock.safe = 0; | 162 SDL_EventLock.safe = 0; |
164 | 163 |
164 /* The event thread will handle timers too */ | |
165 SDL_SetTimerThreaded(2); | |
165 SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL); | 166 SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL); |
166 if ( SDL_EventThread == NULL ) { | 167 if ( SDL_EventThread == NULL ) { |
167 return(-1); | 168 return(-1); |
168 } | 169 } |
169 } else { | 170 } else { |