File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,20 @@ TEST_CASE("poller wait with no handlers throws", "[poller]")
133133 const zmq::error_t &);
134134}
135135
136+ #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 3)
137+ TEST_CASE (" poller add/remove size checks" , " [poller]" )
138+ {
139+ zmq::context_t context;
140+ zmq::socket_t socket{context, zmq::socket_type::router};
141+ zmq::poller_t <> poller;
142+ CHECK (poller.size () == 0 );
143+ poller.add (socket, zmq::event_flags::pollin);
144+ CHECK (poller.size () == 1 );
145+ CHECK_NOTHROW (poller.remove (socket));
146+ CHECK (poller.size () == 0 );
147+ }
148+ #endif
149+
136150TEST_CASE (" poller remove unregistered throws" , " [poller]" )
137151{
138152 zmq::context_t context;
Original file line number Diff line number Diff line change @@ -2654,6 +2654,15 @@ template<typename T = no_user_data> class poller_t
26542654 throw error_t ();
26552655 }
26562656
2657+ #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 3)
2658+ size_t size () const noexcept
2659+ {
2660+ int rc = zmq_poller_size (const_cast <void *>(poller_ptr.get ()));
2661+ ZMQ_ASSERT (rc >= 0 );
2662+ return static_cast <size_t >(std::max (rc, 0 ));
2663+ }
2664+ #endif
2665+
26572666 private:
26582667 struct destroy_poller_t
26592668 {
You can’t perform that action at this time.
0 commit comments