MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / SDL_TimerInit

Function SDL_TimerInit

lib/sdl2/src/timer/SDL_timer.c:206–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206int
207SDL_TimerInit(void)
208{
209 SDL_TimerData *data = &SDL_timer_data;
210
211 if (!SDL_AtomicGet(&data->active)) {
212 const char *name = "SDLTimer";
213 data->timermap_lock = SDL_CreateMutex();
214 if (!data->timermap_lock) {
215 return -1;
216 }
217
218 data->sem = SDL_CreateSemaphore(0);
219 if (!data->sem) {
220 SDL_DestroyMutex(data->timermap_lock);
221 return -1;
222 }
223
224 SDL_AtomicSet(&data->active, 1);
225
226 /* Timer threads use a callback into the app, so we can't set a limited stack size here. */
227 data->thread = SDL_CreateThreadInternal(SDL_TimerThread, name, 0, data);
228 if (!data->thread) {
229 SDL_TimerQuit();
230 return -1;
231 }
232
233 SDL_AtomicSet(&data->nextID, 1);
234 }
235 return 0;
236}
237
238void
239SDL_TimerQuit(void)

Callers 2

SDL_InitSubSystemFunction · 0.85
SDL_AddTimerFunction · 0.85

Calls 7

SDL_AtomicGetFunction · 0.85
SDL_AtomicSetFunction · 0.85
SDL_CreateThreadInternalFunction · 0.85
SDL_TimerQuitFunction · 0.85
SDL_CreateMutexFunction · 0.50
SDL_CreateSemaphoreFunction · 0.50
SDL_DestroyMutexFunction · 0.50

Tested by

no test coverage detected