문제

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);
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top