aboutsummaryrefslogtreecommitdiff
path: root/src/core/reap.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-07 11:44:22 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-07 11:56:22 -0800
commit71e459eea31e9e47c0ce64a78e32b242d357f9a0 (patch)
treec4f6608066aaa6505a5625f399c94845abe6c162 /src/core/reap.c
parent8fa3b2aa8e9191669f137be39ba61ad39243483a (diff)
downloadnng-71e459eea31e9e47c0ce64a78e32b242d357f9a0.tar.gz
nng-71e459eea31e9e47c0ce64a78e32b242d357f9a0.tar.bz2
nng-71e459eea31e9e47c0ce64a78e32b242d357f9a0.zip
fini: add drain mechanism for aio, reap, and task subsystems
Make sure *everything* is drained before proceeding all the way to deallocation.
Diffstat (limited to 'src/core/reap.c')
-rw-r--r--src/core/reap.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/reap.c b/src/core/reap.c
index 3f182205..f996695d 100644
--- a/src/core/reap.c
+++ b/src/core/reap.c
@@ -18,9 +18,9 @@
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 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_work_cv = NNI_CV_INITIALIZER(&reap_mtx);
static nni_cv reap_empty_cv = NNI_CV_INITIALIZER(&reap_mtx);
static void
@@ -90,14 +90,17 @@ nni_reap(nni_reap_list *rl, void *item)
nni_mtx_unlock(&reap_mtx);
}
-void
-nni_reap_drain(void)
+bool
+nni_reap_sys_drain(void)
{
+ bool result = false;
nni_mtx_lock(&reap_mtx);
while (!reap_empty) {
+ result = true;
nni_cv_wait(&reap_empty_cv);
}
nni_mtx_unlock(&reap_mtx);
+ return (result);
}
int