diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-16 22:22:07 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-16 22:22:07 -0800 |
| commit | 4e46e666e47e277316cc680c833356045932bb5f (patch) | |
| tree | d6888f69674a93a3c0a82baafc268773c7bb2976 /src/core/event.c | |
| parent | 50e1484af0d443b46aa04fd4a8096b157dc160aa (diff) | |
| download | nng-4e46e666e47e277316cc680c833356045932bb5f.tar.gz nng-4e46e666e47e277316cc680c833356045932bb5f.tar.bz2 nng-4e46e666e47e277316cc680c833356045932bb5f.zip | |
External event API for send/recv implemented.
This was the main blocker, I think, for the nanomsg legacy compat
shim. Now that we have this, it should be relatively straight-forward
to implement the legacy nanomsg API, including the SENDFD, RECVFD thing.
Diffstat (limited to 'src/core/event.c')
| -rw-r--r-- | src/core/event.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/core/event.c b/src/core/event.c index 1b264632..73bc1c00 100644 --- a/src/core/event.c +++ b/src/core/event.c @@ -95,7 +95,7 @@ nni_notifier(void *arg) // No interest. continue; } - notify->n_func(event, ¬ify->n_arg); + notify->n_func(event, notify->n_arg); } nni_mtx_unlock(&sock->s_notify_mx); @@ -112,3 +112,33 @@ nni_notifier(void *arg) } nni_mtx_unlock(&sock->s_mx); } + + +nni_notify * +nni_add_notify(nni_sock *sock, int mask, nng_notify_func fn, void *arg) +{ + nni_notify *notify; + + if ((notify = NNI_ALLOC_STRUCT(notify)) == NULL) { + return (NULL); + } + notify->n_func = fn; + notify->n_arg = arg; + notify->n_mask = mask; + NNI_LIST_NODE_INIT(¬ify->n_node); + + nni_mtx_lock(&sock->s_notify_mx); + nni_list_append(&sock->s_notify, notify); + nni_mtx_unlock(&sock->s_notify_mx); + return (notify); +} + + +void +nni_rem_notify(nni_sock *sock, nni_notify *notify) +{ + nni_mtx_lock(&sock->s_notify_mx); + nni_list_remove(&sock->s_notify, notify); + nni_mtx_unlock(&sock->s_notify_mx); + NNI_FREE_STRUCT(notify); +} |
