From 3fd43c488b47874db22a87a1d87eed94bbd85725 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 1 Jan 2017 14:34:29 -0800 Subject: Pipe simplifications for thread management. This may also address a race in closing down pipes. Now pipes are always registered with the socket. They also always have both a sender and receiver thread. If the protocol doesn't need one or the other, the stock thread just exits early. --- src/platform/posix/posix_impl.h | 4 ++-- src/platform/posix/posix_thread.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/platform') diff --git a/src/platform/posix/posix_impl.h b/src/platform/posix/posix_impl.h index 5ca7812f..5c5c3798 100644 --- a/src/platform/posix/posix_impl.h +++ b/src/platform/posix/posix_impl.h @@ -54,8 +54,8 @@ struct nni_plat_thr { }; struct nni_plat_cv { - pthread_cond_t cv; - pthread_mutex_t *mtx; + pthread_cond_t cv; + pthread_mutex_t * mtx; }; #endif diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c index 0c928d84..d1944879 100644 --- a/src/platform/posix/posix_thread.c +++ b/src/platform/posix/posix_thread.c @@ -175,6 +175,7 @@ nni_plat_cv_init(nni_plat_cv *cv, nni_plat_mtx *mtx) return (0); } + void nni_plat_cv_wake(nni_plat_cv *cv) { @@ -185,6 +186,7 @@ nni_plat_cv_wake(nni_plat_cv *cv) } } + void nni_plat_cv_wait(nni_plat_cv *cv) { @@ -195,6 +197,7 @@ nni_plat_cv_wait(nni_plat_cv *cv) } } + int nni_plat_cv_until(nni_plat_cv *cv, nni_time until) { @@ -217,9 +220,9 @@ nni_plat_cv_until(nni_plat_cv *cv, nni_time until) nni_panic("pthread_cond_timedwait: %d", rv); } return (0); - } + void nni_plat_cv_fini(nni_plat_cv *cv) { @@ -230,6 +233,7 @@ nni_plat_cv_fini(nni_plat_cv *cv) } } + int nni_plat_thr_init(nni_plat_thr *thr, void (*fn)(void *), void *arg) { @@ -262,7 +266,6 @@ nni_atfork_child(void) } - int nni_plat_init(int (*helper)(void)) { -- cgit v1.2.3-70-g09d2