diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-01-04 10:24:05 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-01-04 10:56:40 -0800 |
| commit | 382b4cff3abd5ccb282ba420ef1f7c7d171ec91a (patch) | |
| tree | 6860e1cceb52a7dab2763001eb27edf95a0e7246 /src/platform/windows/win_thread.c | |
| parent | bcc3814b58e9b198344bdaf6e7a916a354841275 (diff) | |
| download | nng-382b4cff3abd5ccb282ba420ef1f7c7d171ec91a.tar.gz nng-382b4cff3abd5ccb282ba420ef1f7c7d171ec91a.tar.bz2 nng-382b4cff3abd5ccb282ba420ef1f7c7d171ec91a.zip | |
fixes #1105 pollable can be inlined, and use atomics
This also introduces an nni_atomic_cas64 to help with lock-free designs.
Some mechanical renaming was done in some of the protocols for spelling.
Diffstat (limited to 'src/platform/windows/win_thread.c')
| -rw-r--r-- | src/platform/windows/win_thread.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index 70ba73cb..0b77e078 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -213,6 +213,14 @@ nni_atomic_dec64_nv(nni_atomic_u64 *v) #endif } +bool +nni_atomic_cas64(nni_atomic_u64 *v, uint64_t comp, uint64_t new) +{ + uint64_t old; + old = InterlockedCompareExchange64(&v->v, (LONG64)new, (LONG64)comp); + return (old == comp); +} + static unsigned int __stdcall nni_plat_thr_main(void *arg) { nni_plat_thr *thr = arg; |
