Module timer

Available on crate feature dep_sdl3 only.
Expand description

SDL provides time management functionality. It is useful for dealing with (usually) small durations of time.

This is not to be confused with calendar time management, which is provided by CategoryTime.

This category covers measuring time elapsed (SDL_GetTicks(), SDL_GetPerformanceCounter()), putting a thread to sleep for a certain amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing a callback function after a certain amount of time has elasped (SDL_AddTimer(), etc).

There are also useful macros to convert between time units, like SDL_SECONDS_TO_NS() and such.

Constants§

SDL_MS_PER_SECOND
Number of milliseconds in a second.
SDL_NS_PER_MS
Number of nanoseconds in a millisecond.
SDL_NS_PER_SECOND
Number of nanoseconds in a second.
SDL_NS_PER_US
Number of nanoseconds in a microsecond.
SDL_US_PER_SECOND
Number of microseconds in a second.

Functions§

SDL_AddTimer
Call a callback function at a future time.
SDL_AddTimerNS
Call a callback function at a future time.
SDL_Delay
Wait a specified number of milliseconds before returning.
SDL_DelayNS
Wait a specified number of nanoseconds before returning.
SDL_DelayPrecise
Wait a specified number of nanoseconds before returning.
SDL_GetPerformanceCounter
Get the current value of the high resolution counter.
SDL_GetPerformanceFrequency
Get the count per second of the high resolution counter.
SDL_GetTicks
Get the number of milliseconds since SDL library initialization.
SDL_GetTicksNS
Get the number of nanoseconds since SDL library initialization.
SDL_MS_TO_NS
Convert milliseconds to nanoseconds.
SDL_NS_TO_MS
Convert nanoseconds to milliseconds.
SDL_NS_TO_SECONDS
Convert nanoseconds to seconds.
SDL_NS_TO_US
Convert nanoseconds to microseconds.
SDL_RemoveTimer
Remove a timer created with SDL_AddTimer().
SDL_SECONDS_TO_NS
Convert seconds to nanoseconds.
SDL_US_TO_NS
Convert microseconds to nanoseconds.

Type Aliases§

SDL_NSTimerCallback
Function prototype for the nanosecond timer callback function.
SDL_TimerCallback
Function prototype for the millisecond timer callback function.
SDL_TimerID
Definition of the timer ID type.