diff options
author | Chris Robinson <[email protected]> | 2014-04-17 21:39:51 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-17 21:39:51 -0700 |
commit | 6c8bf9ec42b74635e05241a769f70ea5572a335c (patch) | |
tree | 462829a2c824adb0a6cd5de39f539c6cb16fbfec /Alc/threads.c | |
parent | 20e5ec18e1e28b83ecaa588b87973be2cf295e74 (diff) |
Rename althread_once to be more C11-like
Diffstat (limited to 'Alc/threads.c')
-rw-r--r-- | Alc/threads.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Alc/threads.c b/Alc/threads.c index d0aea6e8..d9dabec1 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -294,6 +294,17 @@ int altimespec_get(struct timespec *ts, int base) return 0; } + +void alcall_once(alonce_flag *once, void (*callback)(void)) +{ + LONG ret; + while((ret=InterlockedExchange(once, 1)) == 1) + althrd_yield(); + if(ret == 0) + (*callback)(); + InterlockedExchange(once, 2); +} + #else #include <unistd.h> @@ -304,6 +315,7 @@ int altimespec_get(struct timespec *ts, int base) extern inline int althrd_sleep(const struct timespec *ts, struct timespec *rem); +extern inline void alcall_once(alonce_flag *once, void (*callback)(void)); void althrd_setname(althrd_t thr, const char *name) |