diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-05 18:02:22 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-05 18:02:22 -0800 |
| commit | 1b6e9985960a1079be81a576d52aa7f3fe47c92b (patch) | |
| tree | 2f6c9b33571cf30e28ca721064a9c0d038be4c42 /src/core/thread.c | |
| parent | b17703d1e708a99e9a46ceb012676dc89df40df5 (diff) | |
| download | nng-1b6e9985960a1079be81a576d52aa7f3fe47c92b.tar.gz nng-1b6e9985960a1079be81a576d52aa7f3fe47c92b.tar.bz2 nng-1b6e9985960a1079be81a576d52aa7f3fe47c92b.zip | |
Add nng_shutdown() for sockets to help avoid close race.
Also we added a two phase shutdown for threads.
Diffstat (limited to 'src/core/thread.c')
| -rw-r--r-- | src/core/thread.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/thread.c b/src/core/thread.c index d1f46e3f..74d80513 100644 --- a/src/core/thread.c +++ b/src/core/thread.c @@ -148,6 +148,19 @@ nni_thr_run(nni_thr *thr) void +nni_thr_wait(nni_thr *thr) +{ + nni_plat_mtx_lock(&thr->mtx); + thr->stop = 1; + nni_plat_cv_wake(&thr->cv); + while (!thr->done) { + nni_plat_cv_wait(&thr->cv); + } + nni_plat_mtx_unlock(&thr->mtx); +} + + +void nni_thr_fini(nni_thr *thr) { nni_plat_mtx_lock(&thr->mtx); |
