diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-09-06 13:08:44 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-09-06 13:11:57 -0700 |
| commit | 515cdff883f44fbd192f7d957f47d6e2e1385dd0 (patch) | |
| tree | 7fe06f7e71ed2b7bbaf87c9a917437d219c2182f /src/core/sockimpl.h | |
| parent | 468714a51bbc9fc6acf03479b8825ad25a2ffeb0 (diff) | |
| download | nng-515cdff883f44fbd192f7d957f47d6e2e1385dd0.tar.gz nng-515cdff883f44fbd192f7d957f47d6e2e1385dd0.tar.bz2 nng-515cdff883f44fbd192f7d957f47d6e2e1385dd0.zip | |
Eliminate the pipe mutex and use atomic for pipe closed.
This eliminates several mutex operations done each time a pipe
is created or destroyed. For large scale systems this should
reduce overall pressure on the memory subsystem, and scale better
as many threads are coming and going.
This also reduces the overall size of nni_pipe -- on Linux by
36 bytes typically.
Diffstat (limited to 'src/core/sockimpl.h')
| -rw-r--r-- | src/core/sockimpl.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/sockimpl.h b/src/core/sockimpl.h index 850a4d80..83cbb877 100644 --- a/src/core/sockimpl.h +++ b/src/core/sockimpl.h @@ -104,11 +104,10 @@ struct nni_pipe { nni_sock *p_sock; nni_dialer *p_dialer; nni_listener *p_listener; - bool p_closed; + nni_atomic_bool p_closed; nni_atomic_flag p_stop; bool p_cbs; int p_ref; - nni_mtx p_mtx; nni_cv p_cv; nni_reap_node p_reap; @@ -141,6 +140,7 @@ extern void nni_listener_destroy(nni_listener *); extern void nni_listener_stop(nni_listener *); extern void nni_pipe_remove(nni_pipe *); +extern bool nni_pipe_is_closed(nni_pipe *); extern void nni_pipe_run_cb(nni_pipe *, nng_pipe_ev); extern int nni_pipe_create_dialer(nni_pipe **, nni_dialer *, void *); extern int nni_pipe_create_listener(nni_pipe **, nni_listener *, void *); |
