aboutsummaryrefslogtreecommitdiff
path: root/src/core
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/core
parentc9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04 (diff)
downloadnng-21528dfe0998d056222191a4abe53d8d9f1286e3.tar.gz
nng-21528dfe0998d056222191a4abe53d8d9f1286e3.tar.bz2
nng-21528dfe0998d056222191a4abe53d8d9f1286e3.zip
Static condvar initialization.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/reap.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/core/reap.c b/src/core/reap.c
index 8be5ee12..3f182205 100644
--- a/src/core/reap.c
+++ b/src/core/reap.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -17,11 +17,11 @@
// New stuff.
static nni_reap_list *reap_list = NULL;
static nni_thr reap_thr;
-static bool reap_exit;
-static nni_mtx reap_mtx;
+static bool reap_exit = false;
+static nni_mtx reap_mtx = NNI_MTX_INITIALIZER;
static bool reap_empty;
-static nni_cv reap_work_cv;
-static nni_cv reap_empty_cv;
+static nni_cv reap_work_cv = NNI_CV_INITIALIZER(&reap_mtx);
+static nni_cv reap_empty_cv = NNI_CV_INITIALIZER(&reap_mtx);
static void
reap_worker(void *unused)
@@ -105,17 +105,9 @@ nni_reap_sys_init(void)
{
int rv;
- reap_exit = false;
- nni_mtx_init(&reap_mtx);
- nni_cv_init(&reap_work_cv, &reap_mtx);
- nni_cv_init(&reap_empty_cv, &reap_mtx);
-
// If this fails, we don't fail init, instead we will try to
// start up at reap time.
if ((rv = nni_thr_init(&reap_thr, reap_worker, NULL)) != 0) {
- nni_cv_fini(&reap_work_cv);
- nni_cv_fini(&reap_empty_cv);
- nni_mtx_fini(&reap_mtx);
return (rv);
}
nni_thr_run(&reap_thr);