logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_AddTimerNS - Call a callback function at a future time.

Availability

       This function is available since SDL 3.2.0.

Description

       The  callback  function  is  passed  the  current timer interval and the user supplied parameter from the
       SDL_AddTimerNS () call and should return the next timer interval. If the value returned from the callback
       is 0, the timer is canceled and will be removed.

       The callback is run on a separate thread, and for short timeouts can potentially be  called  before  this
       function returns.

       Timers take into account the amount of time it took to execute the callback. For example, if the callback
       took  250  ns to execute and returned 1000 (ns), the timer would only wait another 750 ns before its next
       iteration.

       Timing may be inexact due to OS scheduling. Be sure to note the current time with SDL_GetTicksNS () or

       SDL_GetPerformanceCounter () in case your callback needs to adjust for variances.

Function Parameters

interval
              the timer delay, in nanoseconds, passed to callback .

       callback
              the SDL_TimerCallback
               function to call when the specified interval elapses.

       userdata
              a pointer that is passed to callback .

Header File

       Defined in SDL3/SDL_timer.h

Name

       SDL_AddTimerNS - Call a callback function at a future time.

Return Value

       ( SDL_TimerID ) Returns a timer ID or 0 on failure; call

       SDL_GetError () for more information.

See Also

(3), SDL_AddTimer(3), (3), SDL_RemoveTimer(3)

Simple Directmedia Layer                           SDL 3.2.10                                  SDL_AddTimerNS(3)

Synopsis

#include"SDL3/SDL.h"SDL_TimerIDSDL_AddTimerNS(Uint64interval,SDL_NSTimerCallbackcallback,void*userdata);

Thread Safety

       It is safe to call this function from any thread.

See Also