Domanda

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);
È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top