mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
add function for adding file descriptor to poller_t
This commit is contained in:
parent
2e6eff0dcc
commit
f51fa9695a
20
zmq.hpp
20
zmq.hpp
@ -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())) {
|
||||
@ -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(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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user