diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-16 11:40:28 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-16 20:56:32 -0700 |
| commit | 45f3f141850a0ac07c31906748752571652683df (patch) | |
| tree | 0e14b8e5a72972e370f60ea5fd230a790195cd28 /src/core/msgqueue.h | |
| parent | e3b8f31b044e4fe7d47439467fc1622266b5335c (diff) | |
| download | nng-45f3f141850a0ac07c31906748752571652683df.tar.gz nng-45f3f141850a0ac07c31906748752571652683df.tar.bz2 nng-45f3f141850a0ac07c31906748752571652683df.zip | |
fixes #344 nn_poll() legacy API missing
This includes the test from legacy libnanomsg and a man page.
We have refactored the message queue notification system so
that it uses nni_pollable, leading we hope to a more consistent
system, and reducing the code size and complexity.
We also fixed the size of the NN_RCVFD and NN_SNDFD so that they
are a SOCKET on Windows systems, rather than an integer. This
addresses 64-bit compilation problems.
Diffstat (limited to 'src/core/msgqueue.h')
| -rw-r--r-- | src/core/msgqueue.h | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/core/msgqueue.h b/src/core/msgqueue.h index 93a26eb6..2d23f448 100644 --- a/src/core/msgqueue.h +++ b/src/core/msgqueue.h @@ -12,6 +12,7 @@ #define CORE_MSGQUEUE_H #include "nng_impl.h" +#include "pollable.h" // Message queues. Message queues work in some ways like Go channels; // they are a thread-safe way to pass messages between subsystems. They @@ -77,28 +78,6 @@ typedef nni_msg *(*nni_msgq_filter)(void *, nni_msg *); // discarded instead, and any get waiters remain waiting. extern void nni_msgq_set_filter(nni_msgq *, nni_msgq_filter, void *); -// nni_msgq_cb_flags is an enumeration of flag bits used with nni_msgq_cb. -enum nni_msgq_cb_flags { - nni_msgq_f_full = 1, - nni_msgq_f_empty = 2, - nni_msgq_f_can_get = 4, - nni_msgq_f_can_put = 8, - nni_msgq_f_closed = 16, -}; - -// nni_msgq_cb is a callback function used by sockets to monitor -// the status of the queue. It is called with the lock held for -// performance reasons so consumers must not re-enter the queue. -// The purpose is to enable file descriptor notifications on the socket, -// which don't need to reenter the msgq. The integer is a mask of -// flags that are true for the given message queue. -typedef void (*nni_msgq_cb)(void *, int); - -// nni_msgq_set_cb sets the callback and argument for the callback -// which will be called on state changes in the message queue. Only -// one callback can be registered on a message queue at a time. -extern void nni_msgq_set_cb(nni_msgq *, nni_msgq_cb, void *); - // nni_msgq_close closes the queue. After this all operates on the // message queue will return NNG_ECLOSED. Messages inside the queue // are freed. Unlike closing a go channel, this operation is idempotent. @@ -119,4 +98,7 @@ extern int nni_msgq_cap(nni_msgq *mq); // nni_msgq_len returns the number of messages currently in the queue. extern int nni_msgq_len(nni_msgq *mq); +extern int nni_msgq_get_recvable(nni_msgq *mq, nni_pollable **); +extern int nni_msgq_get_sendable(nni_msgq *mq, nni_pollable **); + #endif // CORE_MSQUEUE_H |
