Add UtilSleepMillis() function.

This commit is contained in:
Jordan Bancino 2022-08-24 19:30:20 -04:00
parent 8657008e94
commit f950233dbc
2 changed files with 26 additions and 0 deletions

View file

@ -105,3 +105,17 @@ UtilStringDuplicate(char *inStr)
return outStr;
}
int
UtilSleepMillis(long ms)
{
struct timespec ts;
int res;
ts.tv_sec = ms / 1000;
ts.tv_nsec = (ms % 1000) * 1000000;
res = nanosleep(&ts, &ts);
return res;
}

View file

@ -84,4 +84,16 @@ extern char *
extern char *
UtilStringDuplicate(char *);
/*
* Sleep for the given number of milliseconds. This is a simple wrapper
* for nanosleep() that makes its usage much easier.
*
* Params:
* (long) The number of milliseconds to sleep for.
*
* Return: The result of nanosleep().
*/
extern int
UtilSleepMillis(long);
#endif /* TELODENDRIA_UTIL_H */