99{ *
1010 * # CategoryTimer
1111 *
12- * SDL time management routines.
12+ * SDL provides time management functionality. It is useful for dealing with
13+ * (usually) small durations of time.
14+ *
15+ * This is not to be confused with _calendar time_ management, which is
16+ * provided by [CategoryTime](CategoryTime).
17+ *
18+ * This category covers measuring time elapsed (SDL_GetTicks(),
19+ * SDL_GetPerformanceCounter()), putting a thread to sleep for a certain
20+ * amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing
21+ * a callback function after a certain amount of time has elasped
22+ * (SDL_AddTimer(), etc).
23+ *
24+ * There are also useful macros to convert between time units, like
25+ * SDL_SECONDS_TO_NS() and such.
1326 }
1427
1528{ SDL time constants }
1629
1730const
31+ { *
32+ * Number of milliseconds in a second.
33+ *
34+ * This is always 1000.
35+ *
36+ * \since This const is available since SDL 3.2.0.
37+ *}
1838 SDL_MS_PER_SECOND = 1000 ;
39+
40+ { *
41+ * Number of microseconds in a second.
42+ *
43+ * This is always 1000000.
44+ *
45+ * \since This const is available since SDL 3.2.0.
46+ *}
1947 SDL_US_PER_SECOND = 1000000 ;
48+
49+ { *
50+ * Number of nanoseconds in a second.
51+ *
52+ * This is always 1000000000.
53+ *
54+ * \since This const is available since SDL 3.2.0.
55+ *}
2056 SDL_NS_PER_SECOND = 1000000000 ;
57+
58+ { *
59+ * Number of nanoseconds in a millisecond.
60+ *
61+ * This is always 1000000.
62+ *
63+ * \since This macro is available since SDL 3.2.0.
64+ *}
2165 SDL_NS_PER_MS = 1000000 ;
66+
67+ { *
68+ * Number of nanoseconds in a microsecond.
69+ *
70+ * This is always 1000.
71+ *
72+ * \since This macro is available since SDL 3.2.0.
73+ *}
2274 SDL_NS_PER_US = 1000 ;
75+
76+ { *
77+ * Convert seconds to nanoseconds.
78+ *
79+ * This only converts whole numbers, not fractional seconds.
80+ *
81+ * \param S the number of seconds to convert.
82+ * \returns S, expressed in nanoseconds.
83+ *
84+ * \threadsafety It is safe to call this macro from any thread.
85+ *
86+ * \since This macro is available since SDL 3.2.0.
87+ *}
2388function SDL_SECONDS_TO_NS (S: Integer): Integer;
89+
90+ { *
91+ * Convert nanoseconds to seconds.
92+ *
93+ * This performs a division, so the results can be dramatically different if
94+ * `NS` is an integer or floating point value.
95+ *
96+ * \param NS the number of nanoseconds to convert.
97+ * \returns NS, expressed in seconds.
98+ *
99+ * \threadsafety It is safe to call this macro from any thread.
100+ *
101+ * \since This macro is available since SDL 3.2.0.
102+ *}
24103function SDL_NS_TO_SECONDS (NS: Integer): Integer;
104+
105+ { *
106+ * Convert milliseconds to nanoseconds.
107+ *
108+ * This only converts whole numbers, not fractional milliseconds.
109+ *
110+ * \param MS the number of milliseconds to convert.
111+ * \returns MS, expressed in nanoseconds.
112+ *
113+ * \threadsafety It is safe to call this macro from any thread.
114+ *
115+ * \since This macro is available since SDL 3.2.0.
116+ *}
25117function SDL_MS_TO_NS (MS: Integer): Integer;
118+
119+ { *
120+ * Convert nanoseconds to milliseconds.
121+ *
122+ * This performs a division, so the results can be dramatically different if
123+ * `NS` is an integer or floating point value.
124+ *
125+ * \param NS the number of nanoseconds to convert.
126+ * \returns NS, expressed in milliseconds.
127+ *
128+ * \threadsafety It is safe to call this macro from any thread.
129+ *
130+ * \since This macro is available since SDL 3.2.0.
131+ *}
26132function SDL_NS_TO_MS (NS: Integer): Integer;
133+
134+ { *
135+ * Convert microseconds to nanoseconds.
136+ *
137+ * This only converts whole numbers, not fractional microseconds.
138+ *
139+ * \param US the number of microseconds to convert.
140+ * \returns US, expressed in nanoseconds.
141+ *
142+ * \threadsafety It is safe to call this macro from any thread.
143+ *
144+ * \since This macro is available since SDL 3.2.0.
145+ *}
27146function SDL_US_TO_NS (US: Integer): Integer;
147+
148+ { *
149+ * Convert nanoseconds to microseconds.
150+ *
151+ * This performs a division, so the results can be dramatically different if
152+ * `NS` is an integer or floating point value.
153+ *
154+ * \param NS the number of nanoseconds to convert.
155+ * \returns NS, expressed in microseconds.
156+ *
157+ * \threadsafety It is safe to call this macro from any thread.
158+ *
159+ * \since This macro is available since SDL 3.2.0.
160+ *}
28161function SDL_NS_TO_US (NS: Integer): Integer;
29162
30163{ *
@@ -35,7 +168,7 @@ function SDL_NS_TO_US(NS: Integer): Integer;
35168 *
36169 * \threadsafety It is safe to call this function from any thread.
37170 *
38- * \since This function is available since SDL 3.1.3 .
171+ * \since This function is available since SDL 3.2.0 .
39172 }
40173function SDL_GetTicks : cuint64; cdecl;
41174 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetTicks' { $ENDIF} { $ENDIF} ;
@@ -48,7 +181,7 @@ function SDL_GetTicks: cuint64; cdecl;
48181 *
49182 * \threadsafety It is safe to call this function from any thread.
50183 *
51- * \since This function is available since SDL 3.1.3 .
184+ * \since This function is available since SDL 3.2.0 .
52185 }
53186function SDL_GetTicksNS : cuint64; cdecl;
54187 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetTicksNS' { $ENDIF} { $ENDIF} ;
@@ -66,7 +199,7 @@ function SDL_GetTicksNS: cuint64; cdecl;
66199 *
67200 * \threadsafety It is safe to call this function from any thread.
68201 *
69- * \since This function is available since SDL 3.1.3 .
202+ * \since This function is available since SDL 3.2.0 .
70203 *
71204 * \sa SDL_GetPerformanceFrequency
72205 }
@@ -80,7 +213,7 @@ function SDL_GetPerformanceCounter: cuint64; cdecl;
80213 *
81214 * \threadsafety It is safe to call this function from any thread.
82215 *
83- * \since This function is available since SDL 3.1.3 .
216+ * \since This function is available since SDL 3.2.0 .
84217 *
85218 * \sa SDL_GetPerformanceCounter
86219 }
@@ -98,7 +231,10 @@ function SDL_GetPerformanceFrequency: cuint64; cdecl;
98231 *
99232 * \threadsafety It is safe to call this function from any thread.
100233 *
101- * \since This function is available since SDL 3.1.3.
234+ * \since This function is available since SDL 3.2.0.
235+ *
236+ * \sa SDL_DelayNS
237+ * \sa SDL_DelayPrecise
102238 }
103239procedure SDL_Delay (ms: cuint32); cdecl;
104240 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_Delay' { $ENDIF} { $ENDIF} ;
@@ -114,7 +250,10 @@ procedure SDL_Delay(ms: cuint32); cdecl;
114250 *
115251 * \threadsafety It is safe to call this function from any thread.
116252 *
117- * \since This function is available since SDL 3.1.3.
253+ * \since This function is available since SDL 3.2.0.
254+ *
255+ * \sa SDL_Delay
256+ * \sa SDL_DelayPrecise
118257 }
119258procedure SDL_DelayNS (ns: cuint64); cdecl;
120259 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_DelayNS' { $ENDIF} { $ENDIF} ;
@@ -131,14 +270,17 @@ procedure SDL_DelayNS(ns: cuint64); cdecl;
131270 * \threadsafety It is safe to call this function from any thread.
132271 *
133272 * \since This function is available since SDL 3.2.0.
273+ *
274+ * \sa SDL_Delay
275+ * \sa SDL_DelayNS
134276 }
135277procedure SDL_DelayPrecise (ns: cuint64); cdecl;
136278 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_DelayPrecise' { $ENDIF} { $ENDIF} ;
137279
138280{ *
139281 * Definition of the timer ID type.
140282 *
141- * \since This datatype is available since SDL 3.1.3 .
283+ * \since This datatype is available since SDL 3.2.0 .
142284 }
143285type
144286 PPSDL_TimerID = ^PSDL_TimerID;
165307 * thread; the application is responsible for locking resources
166308 * the callback touches that need to be protected.
167309 *
168- * \since This datatype is available since SDL 3.1.3 .
310+ * \since This datatype is available since SDL 3.2.0 .
169311 *
170312 * \sa SDL_AddTimer
171313 }
201343 *
202344 * \threadsafety It is safe to call this function from any thread.
203345 *
204- * \since This function is available since SDL 3.1.3 .
346+ * \since This function is available since SDL 3.2.0 .
205347 *
206348 * \sa SDL_AddTimerNS
207349 * \sa SDL_RemoveTimer
@@ -229,7 +371,7 @@ function SDL_AddTimer(interval: cuint32; callback: TSDL_TimerCallback; userdata:
229371 * thread; the application is responsible for locking resources
230372 * the callback touches that need to be protected.
231373 *
232- * \since This datatype is available since SDL 3.1.3 .
374+ * \since This datatype is available since SDL 3.2.0 .
233375 *
234376 * \sa SDL_AddTimerNS
235377 }
265407 *
266408 * \threadsafety It is safe to call this function from any thread.
267409 *
268- * \since This function is available since SDL 3.1.3 .
410+ * \since This function is available since SDL 3.2.0 .
269411 *
270412 * \sa SDL_AddTimer
271413 * \sa SDL_RemoveTimer
@@ -282,7 +424,7 @@ function SDL_AddTimerNS(interval: cuint64; callback: TSDL_NSTimerCallback; userd
282424 *
283425 * \threadsafety It is safe to call this function from any thread.
284426 *
285- * \since This function is available since SDL 3.1.3 .
427+ * \since This function is available since SDL 3.2.0 .
286428 *
287429 * \sa SDL_AddTimer
288430 }
0 commit comments