From f51fa9695a3fe18f0fe872d3eea3a966901ef188 Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Wed, 7 Jun 2023 14:27:26 +0000 Subject: [PATCH 1/2] add function for adding file descriptor to poller_t --- zmq.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zmq.hpp b/zmq.hpp index f3a5b8a..35f3e76 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -2663,6 +2663,17 @@ template class poller_t add_impl(socket, events, nullptr); } + template< + typename Dummy = void, + typename = + typename std::enable_if::value, Dummy>::type> + void add(fd_t fd, event_flags events, T *user_data) + { + add_impl(fd, events, user_data); + } + + void add(fd_t fd, event_flags events) { add_impl(fd, events, nullptr); } + void remove(zmq::socket_ref socket) { if (0 != zmq_poller_remove(poller_ptr.get(), socket.handle())) { @@ -2729,6 +2740,15 @@ template class poller_t throw error_t(); } } + + void add_impl(fd_t fd, event_flags events, T *user_data) + { + if (0 + != zmq_poller_add(poller_ptr.get(), fd, user_data, + static_cast(events))) { + throw error_t(); + } + } }; #endif // defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER) From 36b6053f92f95e84c0548775b665da167c06dd8f Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Wed, 7 Jun 2023 14:51:03 +0000 Subject: [PATCH 2/2] call the correct function --- zmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index 35f3e76..34fe163 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -2744,8 +2744,8 @@ template class poller_t void add_impl(fd_t fd, event_flags events, T *user_data) { if (0 - != zmq_poller_add(poller_ptr.get(), fd, user_data, - static_cast(events))) { + != zmq_poller_add_fd(poller_ptr.get(), fd, user_data, + static_cast(events))) { throw error_t(); } }