diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-07-02 22:36:08 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-07-03 19:00:19 -0700 |
| commit | d1a9c84a6b375cb25a8b7475957130e364b41753 (patch) | |
| tree | 5444721d96a84d92e3ed258b4d51f80adf6b200c /src/platform/windows/win_thread.c | |
| parent | a772bcc6ebe198f939889abbda18eded2a326941 (diff) | |
| download | nng-d1a9c84a6b375cb25a8b7475957130e364b41753.tar.gz nng-d1a9c84a6b375cb25a8b7475957130e364b41753.tar.bz2 nng-d1a9c84a6b375cb25a8b7475957130e364b41753.zip | |
fixes #572 Several locking errors found
fixes #573 atomic flags could help
This introduces a new atomic flag, and reduces some of the global
locking. The lock refactoring work is not yet complete, but this is
a positive step forward, and should help with certain things.
While here we also fixed a compile warning due to incorrect types.
Diffstat (limited to 'src/platform/windows/win_thread.c')
| -rw-r--r-- | src/platform/windows/win_thread.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index a3d932aa..243811a0 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -103,6 +103,18 @@ nni_plat_cv_fini(nni_plat_cv *cv) NNI_ARG_UNUSED(cv); } +bool +nni_atomic_flag_test_and_set(nni_atomic_flag *f) +{ + return (InterlockedExchange(&f->f, 1) != 0); +} + +void +nni_atomic_flag_reset(nni_atomic_flag *f) +{ + InterlockedExchange(&f->f, 0); +} + static unsigned int __stdcall nni_plat_thr_main(void *arg) { nni_plat_thr *thr = arg; |
