diff options
author | Chris Robinson <[email protected]> | 2014-04-16 06:59:44 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-16 06:59:44 -0700 |
commit | b020dd13fda12ffa275f6c8165dcad481f9658d6 (patch) | |
tree | 8d9ab0e331765c305f62ab4cf609261913333b64 /OpenAL32/Include/threads.h | |
parent | 184cf30cf70d0efcba8cfb7c27f464dbc4a3edaf (diff) |
Avoid using a Sleep() wrapper
Diffstat (limited to 'OpenAL32/Include/threads.h')
-rw-r--r-- | OpenAL32/Include/threads.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/OpenAL32/Include/threads.h b/OpenAL32/Include/threads.h index 84082604..b6a29f65 100644 --- a/OpenAL32/Include/threads.h +++ b/OpenAL32/Include/threads.h @@ -2,6 +2,7 @@ #define AL_THREADS_H #include <time.h> +#include <errno.h> enum { @@ -163,4 +164,15 @@ int almtx_timedlock(almtx_t *mtx, const struct timespec *ts); void SetThreadName(const char *name); + +inline void al_nssleep(time_t sec, long nsec) +{ + struct timespec ts, rem; + ts.tv_sec = sec; + ts.tv_nsec = nsec; + + while(althrd_sleep(&ts, &rem) == -1 && errno == EINTR) + ts = rem; +} + #endif /* AL_THREADS_H */ |