-
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reap: use sys init and fini instead of NNI_CV_INITIALIZER.
The CV_INITIALIZER is error prone, as it cannot use cv_until.
- Loading branch information
Showing
1 changed file
with
11 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright 2021 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2025 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2017 Capitar IT Group BV <[email protected]> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
|
@@ -14,14 +14,13 @@ | |
|
||
#include <stdbool.h> | ||
|
||
// New stuff. | ||
static nni_reap_list *reap_list = NULL; | ||
static nni_thr reap_thr; | ||
static bool reap_exit = false; | ||
static nni_mtx reap_mtx = NNI_MTX_INITIALIZER; | ||
static bool reap_empty; | ||
static nni_cv reap_work_cv = NNI_CV_INITIALIZER(&reap_mtx); | ||
static nni_cv reap_empty_cv = NNI_CV_INITIALIZER(&reap_mtx); | ||
static nni_mtx reap_mtx; | ||
static nni_cv reap_work_cv; | ||
static nni_cv reap_empty_cv; | ||
|
||
static void | ||
reap_worker(void *unused) | ||
|
@@ -109,6 +108,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) { | ||
|
@@ -127,6 +129,10 @@ nni_reap_sys_fini(void) | |
nni_mtx_unlock(&reap_mtx); | ||
nni_thr_fini(&reap_thr); | ||
|
||
nni_cv_fini(&reap_work_cv); | ||
nni_cv_fini(&reap_empty_cv); | ||
nni_mtx_fini(&reap_mtx); | ||
|
||
// NB: The subsystem linkages remain in place. We don't need | ||
// to reinitialize them across future initializations. | ||
} |