Commit 83f41526 authored by Simon Giesecke's avatar Simon Giesecke

Problem: code duplication around options_t::conflate

Solution: extract functionality into get_effective_conflate_option
parent 8820dedc
...@@ -617,15 +617,7 @@ void zmq::ctx_t::connect_inproc_sockets ( ...@@ -617,15 +617,7 @@ void zmq::ctx_t::connect_inproc_sockets (
errno_assert (rc == 0); errno_assert (rc == 0);
} }
bool conflate = if (!get_effective_conflate_option (pending_connection_.endpoint.options)) {
pending_connection_.endpoint.options.conflate
&& (pending_connection_.endpoint.options.type == ZMQ_DEALER
|| pending_connection_.endpoint.options.type == ZMQ_PULL
|| pending_connection_.endpoint.options.type == ZMQ_PUSH
|| pending_connection_.endpoint.options.type == ZMQ_PUB
|| pending_connection_.endpoint.options.type == ZMQ_SUB);
if (!conflate) {
pending_connection_.connect_pipe->set_hwms_boost (bind_options_.sndhwm, pending_connection_.connect_pipe->set_hwms_boost (bind_options_.sndhwm,
bind_options_.rcvhwm); bind_options_.rcvhwm);
pending_connection_.bind_pipe->set_hwms_boost ( pending_connection_.bind_pipe->set_hwms_boost (
......
...@@ -268,6 +268,15 @@ struct options_t ...@@ -268,6 +268,15 @@ struct options_t
std::map<std::string, std::string> app_metadata; std::map<std::string, std::string> app_metadata;
}; };
inline bool get_effective_conflate_option (const options_t &options)
{
// conflate is only effective for some socket types
return options.conflate
&& (options.type == ZMQ_DEALER || options.type == ZMQ_PULL
|| options.type == ZMQ_PUSH || options.type == ZMQ_PUB
|| options.type == ZMQ_SUB);
}
int do_getsockopt (void *const optval_, int do_getsockopt (void *const optval_,
size_t *const optvallen_, size_t *const optvallen_,
const void *value_, const void *value_,
......
...@@ -394,11 +394,7 @@ void zmq::session_base_t::process_attach (i_engine *engine_) ...@@ -394,11 +394,7 @@ void zmq::session_base_t::process_attach (i_engine *engine_)
object_t *parents[2] = {this, _socket}; object_t *parents[2] = {this, _socket};
pipe_t *pipes[2] = {NULL, NULL}; pipe_t *pipes[2] = {NULL, NULL};
bool conflate = const bool conflate = get_effective_conflate_option (options);
options.conflate
&& (options.type == ZMQ_DEALER || options.type == ZMQ_PULL
|| options.type == ZMQ_PUSH || options.type == ZMQ_PUB
|| options.type == ZMQ_SUB);
int hwms[2] = {conflate ? -1 : options.rcvhwm, int hwms[2] = {conflate ? -1 : options.rcvhwm,
conflate ? -1 : options.sndhwm}; conflate ? -1 : options.sndhwm};
......
...@@ -703,11 +703,7 @@ int zmq::socket_base_t::connect (const char *addr_) ...@@ -703,11 +703,7 @@ int zmq::socket_base_t::connect (const char *addr_)
object_t *parents[2] = {this, peer.socket == NULL ? this : peer.socket}; object_t *parents[2] = {this, peer.socket == NULL ? this : peer.socket};
pipe_t *new_pipes[2] = {NULL, NULL}; pipe_t *new_pipes[2] = {NULL, NULL};
const bool conflate = const bool conflate = get_effective_conflate_option (options);
options.conflate
&& (options.type == ZMQ_DEALER || options.type == ZMQ_PULL
|| options.type == ZMQ_PUSH || options.type == ZMQ_PUB
|| options.type == ZMQ_SUB);
int hwms[2] = {conflate ? -1 : sndhwm, conflate ? -1 : rcvhwm}; int hwms[2] = {conflate ? -1 : sndhwm, conflate ? -1 : rcvhwm};
bool conflates[2] = {conflate, conflate}; bool conflates[2] = {conflate, conflate};
...@@ -942,11 +938,7 @@ int zmq::socket_base_t::connect (const char *addr_) ...@@ -942,11 +938,7 @@ int zmq::socket_base_t::connect (const char *addr_)
object_t *parents[2] = {this, session}; object_t *parents[2] = {this, session};
pipe_t *new_pipes[2] = {NULL, NULL}; pipe_t *new_pipes[2] = {NULL, NULL};
const bool conflate = const bool conflate = get_effective_conflate_option (options);
options.conflate
&& (options.type == ZMQ_DEALER || options.type == ZMQ_PULL
|| options.type == ZMQ_PUSH || options.type == ZMQ_PUB
|| options.type == ZMQ_SUB);
int hwms[2] = {conflate ? -1 : options.sndhwm, int hwms[2] = {conflate ? -1 : options.sndhwm,
conflate ? -1 : options.rcvhwm}; conflate ? -1 : options.rcvhwm};
......
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