mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-04-25 01:19:09 +02:00
Merge pull request #451 from gummif/gfa/poller-size
Problem: Poller size function missing
This commit is contained in:
commit
18db4568f9
@ -133,6 +133,20 @@ TEST_CASE("poller wait with no handlers throws", "[poller]")
|
|||||||
const zmq::error_t&);
|
const zmq::error_t&);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 3)
|
||||||
|
TEST_CASE("poller add/remove size checks", "[poller]")
|
||||||
|
{
|
||||||
|
zmq::context_t context;
|
||||||
|
zmq::socket_t socket{context, zmq::socket_type::router};
|
||||||
|
zmq::poller_t<> poller;
|
||||||
|
CHECK(poller.size() == 0);
|
||||||
|
poller.add(socket, zmq::event_flags::pollin);
|
||||||
|
CHECK(poller.size() == 1);
|
||||||
|
CHECK_NOTHROW(poller.remove(socket));
|
||||||
|
CHECK(poller.size() == 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_CASE("poller remove unregistered throws", "[poller]")
|
TEST_CASE("poller remove unregistered throws", "[poller]")
|
||||||
{
|
{
|
||||||
zmq::context_t context;
|
zmq::context_t context;
|
||||||
|
9
zmq.hpp
9
zmq.hpp
@ -2654,6 +2654,15 @@ template<typename T = no_user_data> class poller_t
|
|||||||
throw error_t();
|
throw error_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 3)
|
||||||
|
size_t size() const noexcept
|
||||||
|
{
|
||||||
|
int rc = zmq_poller_size(const_cast<void *>(poller_ptr.get()));
|
||||||
|
ZMQ_ASSERT(rc >= 0);
|
||||||
|
return static_cast<size_t>(std::max(rc, 0));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct destroy_poller_t
|
struct destroy_poller_t
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user