Question

I am not sure if i use the SDL_AddTimer, for 1ms delay each time of invoking, does it hog CPU?

my_timer_id = SDL_AddTimer(delay, my_callbackfunc, my_callback_param);
Was it helpful?

Solution

Timers usually run in separate thread, so you getting a lot of task-switching with this. Same as with SDL_Delay, it isn't guarantee that your process will sleep specified time, - rather at least specified time.

So, the answer for your question is - timers aren't come for free. There will be a cost for their frequent usage, but it is unlikely that you'll notice it. But since you can't rely on timer interval, it isn't looks like a good idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top