From 21528dfe0998d056222191a4abe53d8d9f1286e3 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 5 Dec 2021 23:39:22 -0500 Subject: Static condvar initialization. --- src/core/reap.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/core') 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. +// Copyright 2021 Staysail Systems, Inc. // Copyright 2017 Capitar IT Group BV // // 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); -- cgit v1.2.3-70-g09d2