forked from lda/telodendria
Add UtilSleepMillis() function.
This commit is contained in:
parent
8657008e94
commit
f950233dbc
2 changed files with 26 additions and 0 deletions
14
src/Util.c
14
src/Util.c
|
@ -105,3 +105,17 @@ UtilStringDuplicate(char *inStr)
|
||||||
|
|
||||||
return outStr;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -84,4 +84,16 @@ extern char *
|
||||||
extern char *
|
extern char *
|
||||||
UtilStringDuplicate(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 */
|
#endif /* TELODENDRIA_UTIL_H */
|
||||||
|
|
Loading…
Reference in a new issue