Skip to content

Commit 16a7651

Browse files
committed
Problem: poller_t is copyable, but does not implement copying properly
Solution: make poller_t non-copyable, but properly movable
1 parent 84ab7a0 commit 16a7651

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

zmq.hpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,28 @@ namespace zmq
990990

991991
~poller_t ()
992992
{
993-
zmq_poller_destroy (&poller_ptr);
993+
if (poller_ptr)
994+
{
995+
int rc = zmq_poller_destroy (&poller_ptr);
996+
assert(rc == 0);
997+
}
998+
}
999+
1000+
poller_t(const poller_t&) = delete;
1001+
poller_t &operator=(const poller_t&) = delete;
1002+
poller_t(poller_t&& src)
1003+
: poller_ptr(src.poller_ptr)
1004+
, poller_events(std::move (src.poller_events))
1005+
{
1006+
src.poller_ptr = NULL;
9941007
}
1008+
poller_t &operator=(poller_t&& src)
1009+
{
1010+
poller_ptr = src.poller_ptr;
1011+
poller_events = std::move (src.poller_events);
1012+
src.poller_ptr = NULL;
1013+
return *this;
1014+
}
9951015

9961016
bool add (zmq::socket_t &socket, short events, std::function<void(void)> &handler)
9971017
{

0 commit comments

Comments
 (0)