aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-07-03 08:04:36 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-07-03 08:04:36 +0200
commit191721eaecbc14fc65928c87dcccab9383d55200 (patch)
treef1f5f1da4abbcee8f4b55350ffe4008b4a095345 /src
parent1f499d8aec2625ef812f69cae6831581a9726ee8 (diff)
downloaddabmux-191721eaecbc14fc65928c87dcccab9383d55200.tar.gz
dabmux-191721eaecbc14fc65928c87dcccab9383d55200.tar.bz2
dabmux-191721eaecbc14fc65928c87dcccab9383d55200.zip
update zmq.hpp to support zmq 4.1.x
Diffstat (limited to 'src')
-rw-r--r--src/zmq.hpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/zmq.hpp b/src/zmq.hpp
index 147f096..eb5416e 100644
--- a/src/zmq.hpp
+++ b/src/zmq.hpp
@@ -60,6 +60,15 @@
#define ZMQ_NEW_MONITOR_EVENT_LAYOUT
#endif
+#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 1, 0)
+#define ZMQ_HAS_PROXY_STEERABLE
+/* Socket event data */
+typedef struct {
+ uint16_t event; // id of the event as bitfield
+ int32_t value ; // value is either error code, fd or reconnect interval
+} zmq_event_t;
+#endif
+
// In order to prevent unused variable warnings when building in non-debug
// mode use this macro to make assertions.
#ifndef NDEBUG
@@ -109,7 +118,16 @@ namespace zmq
if (rc != 0)
throw error_t ();
}
-
+
+#ifdef ZMQ_HAS_PROXY_STEERABLE
+ inline void proxy_steerable (void *frontend, void *backend, void *capture, void *control)
+ {
+ int rc = zmq_proxy_steerable (frontend, backend, capture, control);
+ if (rc != 0)
+ throw error_t ();
+ }
+#endif
+
inline void version (int *major_, int *minor_, int *patch_)
{
zmq_version (major_, minor_, patch_);
@@ -254,7 +272,7 @@ namespace zmq
}
- inline explicit context_t (int io_threads_)
+ inline explicit context_t (int io_threads_, int max_sockets_ = ZMQ_MAX_SOCKETS_DFLT)
{
ptr = zmq_ctx_new ();
if (ptr == NULL)
@@ -262,6 +280,9 @@ namespace zmq
int rc = zmq_ctx_set (ptr, ZMQ_IO_THREADS, io_threads_);
ZMQ_ASSERT (rc == 0);
+
+ rc = zmq_ctx_set (ptr, ZMQ_MAX_SOCKETS, max_sockets_);
+ ZMQ_ASSERT (rc == 0);
}
#ifdef ZMQ_HAS_RVALUE_REFS
@@ -420,6 +441,13 @@ namespace zmq
throw error_t ();
}
+#ifdef ZMQ_HAS_RVALUE_REFS
+ inline bool send (message_t &&msg_, int flags_ = 0)
+ {
+ return send(msg_, flags_);
+ }
+#endif
+
inline size_t recv (void *buf_, size_t len_, int flags_ = 0)
{
int nbytes = zmq_recv (ptr, buf_, len_, flags_);
@@ -476,7 +504,15 @@ namespace zmq
if (rc == -1 && zmq_errno() == ETERM)
break;
assert (rc != -1);
- zmq_event_t* event = static_cast<zmq_event_t*>(zmq_msg_data (&eventMsg));
+#if ZMQ_VERSION_MAJOR >= 4
+ const char* data = static_cast<const char*>(zmq_msg_data(&eventMsg));
+ zmq_event_t msgEvent;
+ memcpy(&msgEvent.event, data, sizeof(uint16_t)); data += sizeof(uint16_t);
+ memcpy(&msgEvent.value, data, sizeof(int32_t));
+ zmq_event_t* event = &msgEvent;
+#else
+ zmq_event_t* event = static_cast<zmq_event_t*>(zmq_msg_data(&eventMsg));
+#endif
#ifdef ZMQ_NEW_MONITOR_EVENT_LAYOUT
zmq_msg_t addrMsg;