mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-13 02:42:58 +01:00
Merge pull request #119 from bjovke/master
Allow for empty handler parameter in call to zmq::poller_t::add().
This commit is contained in:
commit
bd1d53dbb5
4
zmq.hpp
4
zmq.hpp
@ -847,7 +847,7 @@ namespace zmq
|
|||||||
|
|
||||||
bool add (zmq::socket_t &socket, short events, std::function<void(void)> &handler)
|
bool add (zmq::socket_t &socket, short events, std::function<void(void)> &handler)
|
||||||
{
|
{
|
||||||
if (0 == zmq_poller_add (poller_ptr, socket.ptr, &handler, events)) {
|
if (0 == zmq_poller_add (poller_ptr, socket.ptr, handler ? &handler : NULL, events)) {
|
||||||
poller_events.emplace_back (zmq_poller_event_t ());
|
poller_events.emplace_back (zmq_poller_event_t ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -868,7 +868,7 @@ namespace zmq
|
|||||||
int rc = zmq_poller_wait_all (poller_ptr, poller_events.data (), poller_events.size (), static_cast<long>(timeout.count ()));
|
int rc = zmq_poller_wait_all (poller_ptr, poller_events.data (), poller_events.size (), static_cast<long>(timeout.count ()));
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
std::for_each (poller_events.begin (), poller_events.begin () + rc, [](zmq_poller_event_t& event) {
|
std::for_each (poller_events.begin (), poller_events.begin () + rc, [](zmq_poller_event_t& event) {
|
||||||
(*reinterpret_cast<std::function<void(void)>*> (event.user_data)) ();
|
if (event.user_data != NULL) (*reinterpret_cast<std::function<void(void)>*> (event.user_data)) ();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user