summaryrefslogtreecommitdiff
path: root/src/sub.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-05-28 09:02:21 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-05-28 09:02:21 +0200
commit311fb0d852374e769d8ff791c9df38f0464960c6 (patch)
treea375bed4c85bbbdb57e7c749997b95e6062ef18c /src/sub.hpp
parent718885fdcd7af797f940078ca8c22aebab93c8bb (diff)
Subscription matching moved from XSUB to SUB socket
This patch will prevent duplicate matching in devices in the future. Instead of matching in both XPUB and XSUB, it'll happen only in XPUB. Receiver endpoint will still filter messages via SUB socket. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/sub.hpp')
-rw-r--r--src/sub.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/sub.hpp b/src/sub.hpp
index 8ba8987..91a5b65 100644
--- a/src/sub.hpp
+++ b/src/sub.hpp
@@ -22,6 +22,8 @@
#define __ZMQ_SUB_HPP_INCLUDED__
#include "xsub.hpp"
+#include "trie.hpp"
+#include "msg.hpp"
namespace zmq
{
@@ -38,9 +40,26 @@ namespace zmq
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
int xsend (class msg_t *msg_, int options_);
bool xhas_out ();
+ int xrecv (class msg_t *msg_, int flags_);
+ bool xhas_in ();
private:
+ // Check whether the message matches at least one subscription.
+ bool match (class msg_t *msg_);
+
+ // The repository of subscriptions.
+ trie_t subscriptions;
+
+ // If true, 'message' contains a matching message to return on the
+ // next recv call.
+ bool has_message;
+ msg_t message;
+
+ // If true, part of a multipart message was already received, but
+ // there are following parts still waiting.
+ bool more;
+
sub_t (const sub_t&);
const sub_t &operator = (const sub_t&);
};