Skip to content

Commit 590cf71

Browse files
authored
Merge pull request #227 from sigiesec/poller-wait-all-return-sizet
Problem: poller_t::wait_all and active_poller_t::wait declare int ret…
2 parents bc82352 + 65ae6b3 commit 590cf71

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

zmq.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,14 +1091,14 @@ template <typename T = void> class poller_t
10911091
}
10921092
}
10931093

1094-
int wait_all (std::vector<zmq_poller_event_t> &poller_events,
1095-
const std::chrono::microseconds timeout)
1094+
size_t wait_all (std::vector<zmq_poller_event_t> &poller_events,
1095+
const std::chrono::microseconds timeout)
10961096
{
10971097
int rc = zmq_poller_wait_all (poller_ptr.get (), poller_events.data (),
10981098
static_cast<int> (poller_events.size ()),
10991099
static_cast<long> (timeout.count ()));
11001100
if (rc > 0)
1101-
return rc;
1101+
return static_cast<size_t> (rc);
11021102

11031103
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3)
11041104
if (zmq_errno () == EAGAIN)

zmq_addon.hpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class active_poller_t
398398
base_poller.modify (socket, events);
399399
}
400400

401-
int wait (std::chrono::milliseconds timeout)
401+
size_t wait (std::chrono::milliseconds timeout)
402402
{
403403
if (need_rebuild) {
404404
poller_events.resize (handlers.size ());
@@ -409,16 +409,13 @@ class active_poller_t
409409
}
410410
need_rebuild = false;
411411
}
412-
const int count = base_poller.wait_all (poller_events, timeout);
413-
if (count != 0) {
414-
std::for_each (poller_events.begin (),
415-
poller_events.begin () + count,
416-
[](zmq_poller_event_t &event) {
417-
if (event.user_data != NULL)
418-
(*reinterpret_cast<handler_t *> (
419-
event.user_data)) (event.events);
420-
});
421-
}
412+
const auto count = base_poller.wait_all (poller_events, timeout);
413+
std::for_each (poller_events.begin (), poller_events.begin () + count,
414+
[](zmq_poller_event_t &event) {
415+
if (event.user_data != NULL)
416+
(*reinterpret_cast<handler_t *> (
417+
event.user_data)) (event.events);
418+
});
422419
return count;
423420
}
424421

0 commit comments

Comments
 (0)