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]")
192
192
CHECK (&i == events[0 ].user_data );
193
193
}
194
194
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
+
195
210
TEST_CASE (" poller add invalid socket throws" , " [poller]" )
196
211
{
197
212
zmq::context_t context;
Original file line number Diff line number Diff line change 108
108
#include < cassert>
109
109
#include < cstring>
110
110
111
+ #include < type_traits>
111
112
#include < algorithm>
112
113
#include < exception>
113
114
#include < iomanip>
@@ -2714,9 +2715,12 @@ template<typename T = no_user_data> class poller_t
2714
2715
}
2715
2716
}
2716
2717
2717
- size_t wait_all (std::vector<event_type> &poller_events,
2718
+ template <typename Sequence>
2719
+ size_t wait_all (Sequence &poller_events,
2718
2720
const std::chrono::milliseconds timeout)
2719
2721
{
2722
+ static_assert (std::is_same<typename Sequence::value_type, event_type>::value,
2723
+ " Sequence::value_type must be of poller_t::event_type" );
2720
2724
int rc = zmq_poller_wait_all (
2721
2725
poller_ptr.get (),
2722
2726
reinterpret_cast <zmq_poller_event_t *>(poller_events.data ()),
You can’t perform that action at this time.
0 commit comments