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_
Delay ⚠Precise - Wait a specified number of nanoseconds before returning.
- SDL_
GetPerformance ⚠Counter - Get the current value of the high resolution counter.
- SDL_
GetPerformance ⚠Frequency - 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_
Remove ⚠Timer - 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_
NSTimer Callback - Function prototype for the nanosecond timer callback function.
- SDL_
Timer Callback - Function prototype for the millisecond timer callback function.
- SDL_
TimerID - Definition of the timer ID type.