File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,21 @@ TEST_CASE("poller poll basic", "[poller]")
192192 CHECK (&i == events[0 ].user_data );
193193}
194194
195+ TEST_CASE (" poller poll basic static array" , " [poller]" )
196+ {
197+ common_server_client_setup s;
198+
199+ CHECK_NOTHROW (s.client .send (zmq::message_t {hi_str}, zmq::send_flags::none));
200+
201+ zmq::poller_t <int > poller;
202+ std::array<zmq::poller_event<int >, 1 > events;
203+ int i = 0 ;
204+ CHECK_NOTHROW (poller.add (s.server , zmq::event_flags::pollin, &i));
205+ CHECK (1 == poller.wait_all (events, std::chrono::milliseconds{-1 }));
206+ CHECK (s.server == events[0 ].socket );
207+ CHECK (&i == events[0 ].user_data );
208+ }
209+
195210TEST_CASE (" poller add invalid socket throws" , " [poller]" )
196211{
197212 zmq::context_t context;
Original file line number Diff line number Diff line change 108108#include < cassert>
109109#include < cstring>
110110
111+ #include < type_traits>
111112#include < algorithm>
112113#include < exception>
113114#include < iomanip>
@@ -2714,9 +2715,12 @@ template<typename T = no_user_data> class poller_t
27142715 }
27152716 }
27162717
2717- size_t wait_all (std::vector<event_type> &poller_events,
2718+ template <typename Sequence>
2719+ size_t wait_all (Sequence &poller_events,
27182720 const std::chrono::milliseconds timeout)
27192721 {
2722+ static_assert (std::is_same<typename Sequence::value_type, event_type>::value,
2723+ " Sequence::value_type must be of poller_t::event_type" );
27202724 int rc = zmq_poller_wait_all (
27212725 poller_ptr.get (),
27222726 reinterpret_cast <zmq_poller_event_t *>(poller_events.data ()),
You can’t perform that action at this time.
0 commit comments