mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-03-03 12:58:05 +01:00
Problem: poller's constructor is not default
Solution: Constructor logic moved to the same place where cleanup is and marking constructor `default`. Init/cleanup code is in one pleace making it easier to read/maintain.
This commit is contained in:
parent
2aba0bb3ac
commit
c03fb35173
14
zmq.hpp
14
zmq.hpp
@ -1018,12 +1018,7 @@ namespace zmq
|
|||||||
class poller_t
|
class poller_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
poller_t ()
|
poller_t () = default;
|
||||||
{
|
|
||||||
if (!poller_ptr)
|
|
||||||
throw error_t ();
|
|
||||||
}
|
|
||||||
|
|
||||||
~poller_t () = default;
|
~poller_t () = default;
|
||||||
|
|
||||||
poller_t(const poller_t&) = delete;
|
poller_t(const poller_t&) = delete;
|
||||||
@ -1112,7 +1107,12 @@ namespace zmq
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<void, std::function<void(void*)>> poller_ptr
|
std::unique_ptr<void, std::function<void(void*)>> poller_ptr
|
||||||
{
|
{
|
||||||
zmq_poller_new (),
|
[]() {
|
||||||
|
auto poller_new = zmq_poller_new ();
|
||||||
|
if (poller_new)
|
||||||
|
return poller_new;
|
||||||
|
throw error_t ();
|
||||||
|
}(),
|
||||||
[](void *ptr) {
|
[](void *ptr) {
|
||||||
int rc = zmq_poller_destroy (&ptr);
|
int rc = zmq_poller_destroy (&ptr);
|
||||||
ZMQ_ASSERT (rc == 0);
|
ZMQ_ASSERT (rc == 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user