aboutsummaryrefslogtreecommitdiff
path: root/src/nng.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-05-17 12:54:01 -0700
committerGarrett D'Amore <garrett@damore.org>2018-05-17 19:29:37 -0700
commit70d478f5d185e147ca8d3dcba4cbd8bb6da3719a (patch)
tree443e3b0e81138d7c195660d45eca7d4d497af8ac /src/nng.h
parente490aa3353f05e158a0f1f485f371cd49e70b4f5 (diff)
downloadnng-70d478f5d185e147ca8d3dcba4cbd8bb6da3719a.tar.gz
nng-70d478f5d185e147ca8d3dcba4cbd8bb6da3719a.tar.bz2
nng-70d478f5d185e147ca8d3dcba4cbd8bb6da3719a.zip
fixes #449 Want more flexible pipe events
This changes the signature of nng_pipe_notify(), and the associated events. The documentation is updated to reflect this. We have also broken the lock up so that we don't hold the master socket lock for some of these things, which may have beneficial impact on performance.
Diffstat (limited to 'src/nng.h')
-rw-r--r--src/nng.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/nng.h b/src/nng.h
index 0c62dcb9..19823f0d 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -223,12 +223,18 @@ NNG_DECL int nng_getopt_ptr(nng_socket, const char *, void **);
// Only one callback can be set on a given socket, and there is no way
// to retrieve the old value.
typedef enum {
- NNG_PIPE_ADD, // Pipe added to socket
- NNG_PIPE_REM // Pipe removed from socket
-} nng_pipe_action;
-
-typedef void (*nng_pipe_cb)(nng_pipe, nng_pipe_action, void *);
-NNG_DECL int nng_pipe_notify(nng_socket, nng_pipe_cb, void *);
+ NNG_PIPE_EV_ADD_PRE, // Called just before pipe added to socket
+ NNG_PIPE_EV_ADD_POST, // Called just after pipe added to socket
+ NNG_PIPE_EV_REM_POST, // Called just after poipe removed from socket
+ NNG_PIPE_EV_NUM, // Used internally, must be last.
+} nng_pipe_ev;
+
+typedef void (*nng_pipe_cb)(nng_pipe, int, void *);
+
+// nng_pipe_notify registers a callback to be executed when the
+// given event is triggered. To watch for different events, register
+// multiple times. Each event can have at most one callback registered.
+NNG_DECL int nng_pipe_notify(nng_socket, int, nng_pipe_cb, void *);
// nng_getopt_string is special -- it allocates a string to hold the
// resulting string, which should be freed with nng_strfree when it is