Commit 58c9830d authored by Martin Sustrik's avatar Martin Sustrik

XSUB socket has a subscription distributor

Signed-off-by: 's avatarMartin Sustrik <sustrik@250bpm.com>
parent 8eae7d85
...@@ -27,12 +27,13 @@ ...@@ -27,12 +27,13 @@
zmq::xsub_t::xsub_t (class ctx_t *parent_, uint32_t tid_) : zmq::xsub_t::xsub_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, tid_), socket_base_t (parent_, tid_),
fq (this), fq (this),
dist (this),
has_message (false), has_message (false),
more (false) more (false)
{ {
options.type = ZMQ_XSUB; options.type = ZMQ_XSUB;
options.requires_in = true; options.requires_in = true;
options.requires_out = false; options.requires_out = true;
zmq_msg_init (&message); zmq_msg_init (&message);
} }
...@@ -44,13 +45,15 @@ zmq::xsub_t::~xsub_t () ...@@ -44,13 +45,15 @@ zmq::xsub_t::~xsub_t ()
void zmq::xsub_t::xattach_pipes (class reader_t *inpipe_, void zmq::xsub_t::xattach_pipes (class reader_t *inpipe_,
class writer_t *outpipe_, const blob_t &peer_identity_) class writer_t *outpipe_, const blob_t &peer_identity_)
{ {
zmq_assert (inpipe_ && !outpipe_); zmq_assert (inpipe_ && outpipe_);
fq.attach (inpipe_); fq.attach (inpipe_);
dist.attach (outpipe_);
} }
void zmq::xsub_t::process_term (int linger_) void zmq::xsub_t::process_term (int linger_)
{ {
fq.terminate (); fq.terminate ();
dist.terminate ();
socket_base_t::process_term (linger_); socket_base_t::process_term (linger_);
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "trie.hpp" #include "trie.hpp"
#include "socket_base.hpp" #include "socket_base.hpp"
#include "dist.hpp"
#include "fq.hpp" #include "fq.hpp"
namespace zmq namespace zmq
...@@ -57,6 +58,9 @@ namespace zmq ...@@ -57,6 +58,9 @@ namespace zmq
// Fair queueing object for inbound pipes. // Fair queueing object for inbound pipes.
fq_t fq; fq_t fq;
// Distributor mechanism for outbound messages (subscriptions).
dist_t dist;
// The repository of subscriptions. // The repository of subscriptions.
trie_t subscriptions; trie_t subscriptions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment