mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 07:56:09 +00:00
Problem: many unnecessary ifdefs covering new xpub option
Solution: remove them, only public headers have to be ifdef'd
This commit is contained in:
parent
9bcfc251f4
commit
a53dfe936a
17
src/xpub.cpp
17
src/xpub.cpp
@ -44,9 +44,7 @@ zmq::xpub_t::xpub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
|
|||||||
_more (false),
|
_more (false),
|
||||||
_lossy (true),
|
_lossy (true),
|
||||||
_manual (false),
|
_manual (false),
|
||||||
#ifdef ZMQ_BUILD_DRAFT_API
|
|
||||||
_send_last_pipe (false),
|
_send_last_pipe (false),
|
||||||
#endif
|
|
||||||
_pending_pipes (),
|
_pending_pipes (),
|
||||||
_welcome_msg ()
|
_welcome_msg ()
|
||||||
{
|
{
|
||||||
@ -193,10 +191,8 @@ int zmq::xpub_t::xsetsockopt (int option_,
|
|||||||
size_t optvallen_)
|
size_t optvallen_)
|
||||||
{
|
{
|
||||||
if (option_ == ZMQ_XPUB_VERBOSE || option_ == ZMQ_XPUB_VERBOSER
|
if (option_ == ZMQ_XPUB_VERBOSE || option_ == ZMQ_XPUB_VERBOSER
|
||||||
#ifdef ZMQ_BUILD_DRAFT_API
|
|| option_ == ZMQ_XPUB_MANUAL_LAST_VALUE || option_ == ZMQ_XPUB_NODROP
|
||||||
|| option_ == ZMQ_XPUB_MANUAL_LAST_VALUE
|
|| option_ == ZMQ_XPUB_MANUAL) {
|
||||||
#endif
|
|
||||||
|| option_ == ZMQ_XPUB_NODROP || option_ == ZMQ_XPUB_MANUAL) {
|
|
||||||
if (optvallen_ != sizeof (int)
|
if (optvallen_ != sizeof (int)
|
||||||
|| *static_cast<const int *> (optval_) < 0) {
|
|| *static_cast<const int *> (optval_) < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -208,11 +204,9 @@ int zmq::xpub_t::xsetsockopt (int option_,
|
|||||||
} else if (option_ == ZMQ_XPUB_VERBOSER) {
|
} else if (option_ == ZMQ_XPUB_VERBOSER) {
|
||||||
_verbose_subs = (*static_cast<const int *> (optval_) != 0);
|
_verbose_subs = (*static_cast<const int *> (optval_) != 0);
|
||||||
_verbose_unsubs = _verbose_subs;
|
_verbose_unsubs = _verbose_subs;
|
||||||
#ifdef ZMQ_BUILD_DRAFT_API
|
|
||||||
} else if (option_ == ZMQ_XPUB_MANUAL_LAST_VALUE) {
|
} else if (option_ == ZMQ_XPUB_MANUAL_LAST_VALUE) {
|
||||||
_manual = (*static_cast<const int *> (optval_) != 0);
|
_manual = (*static_cast<const int *> (optval_) != 0);
|
||||||
_send_last_pipe = _manual;
|
_send_last_pipe = _manual;
|
||||||
#endif
|
|
||||||
} else if (option_ == ZMQ_XPUB_NODROP)
|
} else if (option_ == ZMQ_XPUB_NODROP)
|
||||||
_lossy = (*static_cast<const int *> (optval_) == 0);
|
_lossy = (*static_cast<const int *> (optval_) == 0);
|
||||||
else if (option_ == ZMQ_XPUB_MANUAL)
|
else if (option_ == ZMQ_XPUB_MANUAL)
|
||||||
@ -276,13 +270,11 @@ void zmq::xpub_t::mark_as_matching (pipe_t *pipe_, xpub_t *self_)
|
|||||||
self_->_dist.match (pipe_);
|
self_->_dist.match (pipe_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZMQ_BUILD_DRAFT_API
|
|
||||||
void zmq::xpub_t::mark_last_pipe_as_matching (pipe_t *pipe_, xpub_t *self_)
|
void zmq::xpub_t::mark_last_pipe_as_matching (pipe_t *pipe_, xpub_t *self_)
|
||||||
{
|
{
|
||||||
if (self_->_last_pipe == pipe_)
|
if (self_->_last_pipe == pipe_)
|
||||||
self_->_dist.match (pipe_);
|
self_->_dist.match (pipe_);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int zmq::xpub_t::xsend (msg_t *msg_)
|
int zmq::xpub_t::xsend (msg_t *msg_)
|
||||||
{
|
{
|
||||||
@ -290,7 +282,6 @@ int zmq::xpub_t::xsend (msg_t *msg_)
|
|||||||
|
|
||||||
// For the first part of multi-part message, find the matching pipes.
|
// For the first part of multi-part message, find the matching pipes.
|
||||||
if (!_more) {
|
if (!_more) {
|
||||||
#ifdef ZMQ_BUILD_DRAFT_API
|
|
||||||
if (_manual && _last_pipe && _send_last_pipe) {
|
if (_manual && _last_pipe && _send_last_pipe) {
|
||||||
_subscriptions.match (static_cast<unsigned char *> (msg_->data ()),
|
_subscriptions.match (static_cast<unsigned char *> (msg_->data ()),
|
||||||
msg_->size (), mark_last_pipe_as_matching,
|
msg_->size (), mark_last_pipe_as_matching,
|
||||||
@ -299,10 +290,6 @@ int zmq::xpub_t::xsend (msg_t *msg_)
|
|||||||
} else
|
} else
|
||||||
_subscriptions.match (static_cast<unsigned char *> (msg_->data ()),
|
_subscriptions.match (static_cast<unsigned char *> (msg_->data ()),
|
||||||
msg_->size (), mark_as_matching, this);
|
msg_->size (), mark_as_matching, this);
|
||||||
#else
|
|
||||||
_subscriptions.match (static_cast<unsigned char *> (msg_->data ()),
|
|
||||||
msg_->size (), mark_as_matching, this);
|
|
||||||
#endif
|
|
||||||
// If inverted matching is used, reverse the selection now
|
// If inverted matching is used, reverse the selection now
|
||||||
if (options.invert_matching) {
|
if (options.invert_matching) {
|
||||||
_dist.reverse_match ();
|
_dist.reverse_match ();
|
||||||
|
@ -99,13 +99,11 @@ class xpub_t : public socket_base_t
|
|||||||
// Subscriptions will not bed added automatically, only after calling set option with ZMQ_SUBSCRIBE or ZMQ_UNSUBSCRIBE
|
// Subscriptions will not bed added automatically, only after calling set option with ZMQ_SUBSCRIBE or ZMQ_UNSUBSCRIBE
|
||||||
bool _manual;
|
bool _manual;
|
||||||
|
|
||||||
#ifdef ZMQ_BUILD_DRAFT_API
|
|
||||||
// Send message to the last pipe, only used if xpub is on manual and after calling set option with ZMQ_SUBSCRIBE
|
// Send message to the last pipe, only used if xpub is on manual and after calling set option with ZMQ_SUBSCRIBE
|
||||||
bool _send_last_pipe;
|
bool _send_last_pipe;
|
||||||
|
|
||||||
// Function to be applied to match the last pipe.
|
// Function to be applied to match the last pipe.
|
||||||
static void mark_last_pipe_as_matching (zmq::pipe_t *pipe_, xpub_t *arg_);
|
static void mark_last_pipe_as_matching (zmq::pipe_t *pipe_, xpub_t *arg_);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Last pipe that sent subscription message, only used if xpub is on manual
|
// Last pipe that sent subscription message, only used if xpub is on manual
|
||||||
pipe_t *_last_pipe;
|
pipe_t *_last_pipe;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user