X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fresolve.h;h=212a7f0a47574068b1b7573acf973ef76cbbc5ca;hb=593c8202bf8c6ecc563aaacf0811aef953b45f09;hp=5e7781dfc64a3e66bf16d1b02c8beed05aaefc83;hpb=b91b37fd6534a8e546fd6f5d6ddd91d66cd0519f;p=libs%2Fnet.git diff --git a/source/net/resolve.h b/source/net/resolve.h index 5e7781d..212a7f0 100644 --- a/source/net/resolve.h +++ b/source/net/resolve.h @@ -2,19 +2,18 @@ #define MSP_NET_RESOLVE_H_ #include +#include #include #include #include #include #include #include -#include "constants.h" +#include "sockaddr.h" namespace Msp { namespace Net { -class SockAddr; - /** Resolves host and service names into a socket address. If host is empty, the loopback address will be used. If host is "*", the wildcard address will be used. If service is empty, a socket address with a null service will be @@ -36,14 +35,12 @@ class Resolver private: struct Task { - unsigned tag; + unsigned tag = 0; std::string host; std::string serv; - Family family; - SockAddr *addr; - std::runtime_error *error; - - Task(); + Family family = UNSPEC; + std::unique_ptr addr; + std::unique_ptr error; bool is_complete() const { return addr || error; } }; @@ -55,20 +52,20 @@ private: Mutex queue_mutex; Semaphore sem; IO::Pipe notify_pipe; - bool done; + bool done = false; public: WorkerThread(); ~WorkerThread(); - void add_task(const Task &); + void add_task(Task &&); Task *get_complete_task(); void pop_complete_task(); IO::Pipe &get_notify_pipe() { return notify_pipe; } private: - virtual void main(); + void main() override; }; public: @@ -76,9 +73,9 @@ public: sigc::signal signal_resolve_failed; private: - IO::EventDispatcher *event_disp; + IO::EventDispatcher *event_disp = nullptr; WorkerThread thread; - unsigned next_tag; + unsigned next_tag = 1; public: Resolver();