diff options
author | Chris Robinson <[email protected]> | 2014-04-16 05:32:55 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-16 05:32:55 -0700 |
commit | e8517d8600ee7163e3a11a9b32f981081fe37318 (patch) | |
tree | 24ba238b8c00e640c7fe237a148560ce6e1d2a52 /Alc | |
parent | 18ab9cbbdd4b8db8e5cd9ea6155efafdb79fcad0 (diff) |
Fix Windows' almtx_timedlock
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/helpers.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 7e6b59a5..78367c77 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -408,21 +408,21 @@ void almtx_destroy(almtx_t *mtx) int almtx_timedlock(almtx_t *mtx, const struct timespec *ts) { - DWORD expire; + DWORD start, timelen; int ret; if(!mtx || !ts) return althrd_error; - expire = ts->tv_sec * 1000; - expire += (ts->tv_nsec+999999) / 1000000; - expire += timeGetTime(); + timelen = ts->tv_sec * 1000; + timelen += (ts->tv_nsec+999999) / 1000000; + start = timeGetTime(); while((ret=almtx_trylock(mtx)) == althrd_busy) { DWORD now = timeGetTime(); - if(expire <= now) break; - // busy loop! + if(now-start >= timelen) + break; SwitchToThread(); } |