aboutsummaryrefslogtreecommitdiff
path: root/src/platform/windows
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-05 23:39:22 -0500
committerGarrett D'Amore <garrett@damore.org>2021-12-05 23:39:22 -0500
commit21528dfe0998d056222191a4abe53d8d9f1286e3 (patch)
tree3231c744883aa89af32e75f2d775e1cc8b63c1f8 /src/platform/windows
parentc9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04 (diff)
downloadnng-21528dfe0998d056222191a4abe53d8d9f1286e3.tar.gz
nng-21528dfe0998d056222191a4abe53d8d9f1286e3.tar.bz2
nng-21528dfe0998d056222191a4abe53d8d9f1286e3.zip
Static condvar initialization.
Diffstat (limited to 'src/platform/windows')
-rw-r--r--src/platform/windows/win_impl.h2
-rw-r--r--src/platform/windows/win_resolv.c14
2 files changed, 7 insertions, 9 deletions
diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h
index b3c08edf..bbd007d0 100644
--- a/src/platform/windows/win_impl.h
+++ b/src/platform/windows/win_impl.h
@@ -53,6 +53,8 @@ struct nni_plat_cv {
PSRWLOCK srl;
};
+#define NNI_CV_INITIALIZER(mxp) { .srl = mxp, .cv = CONDITION_VARIABLE_INIT }
+
struct nni_atomic_flag {
unsigned f;
};
diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c
index 8628719f..f855e255 100644
--- a/src/platform/windows/win_resolv.c
+++ b/src/platform/windows/win_resolv.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -26,9 +26,9 @@
#define NNG_RESOLV_CONCURRENCY 4
#endif
-static nni_mtx resolv_mtx;
-static nni_cv resolv_cv;
-static bool resolv_fini;
+static nni_mtx resolv_mtx = NNI_MTX_INITIALIZER;
+static nni_cv resolv_cv = NNI_CV_INITIALIZER(&resolv_mtx);
+static bool resolv_fini = false;
static nni_list resolv_aios;
static nni_thr resolv_thrs[NNG_RESOLV_CONCURRENCY];
@@ -408,11 +408,9 @@ nni_parse_ip_port(const char *addr, nni_sockaddr *sa)
int
nni_win_resolv_sysinit(void)
{
- nni_mtx_init(&resolv_mtx);
- nni_cv_init(&resolv_cv, &resolv_mtx);
nni_aio_list_init(&resolv_aios);
-
resolv_fini = false;
+
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) {
int rv = nni_thr_init(&resolv_thrs[i], resolv_worker, NULL);
if (rv != 0) {
@@ -437,8 +435,6 @@ nni_win_resolv_sysfini(void)
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) {
nni_thr_fini(&resolv_thrs[i]);
}
- nni_cv_fini(&resolv_cv);
- nni_mtx_fini(&resolv_mtx);
}
#endif // NNG_PLATFORM_WINDOWS