Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function for adding file descriptor to poller_t #595

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,17 @@ template<typename T = no_user_data> class poller_t
add_impl(socket, events, nullptr);
}

template<
typename Dummy = void,
typename =
typename std::enable_if<!std::is_same<T, no_user_data>::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())) {
Expand Down Expand Up @@ -2729,6 +2740,15 @@ template<typename T = no_user_data> class poller_t
throw error_t();
}
}

void add_impl(fd_t fd, event_flags events, T *user_data)
{
if (0
!= zmq_poller_add_fd(poller_ptr.get(), fd, user_data,
static_cast<short>(events))) {
throw error_t();
}
}
};
#endif // defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)

Expand Down
Loading