E-MailRelay
|
A 'future' shared-state class for asynchronous name resolution that holds parameters and results of a call to getaddrinfo(), as performed by the run() method. More...
#include <gresolverfuture.h>
Classes | |
struct | Result |
Result structure for GNet::ResolverFuture::get(). More... | |
Public Types | |
using | List = std::vector< Address > |
Public Member Functions | |
ResolverFuture (const std::string &host, const std::string &service, int family, const Resolver::Config &) | |
Constructor for resolving the given host and service names. More... | |
~ResolverFuture () | |
Destructor. More... | |
ResolverFuture & | run () noexcept |
Does the synchronous name resolution and stores the result. More... | |
Result | get () |
Returns the resolved address after run() has completed. More... | |
void | get (List &) |
Returns by reference the resolved addresses after run() has completed by appending to the given list. More... | |
bool | error () const |
Returns true if name resolution failed or no suitable address was returned. More... | |
std::string | reason () const |
Returns the reason for the error(). More... | |
ResolverFuture (const ResolverFuture &)=delete | |
ResolverFuture (ResolverFuture &&)=delete | |
ResolverFuture & | operator= (const ResolverFuture &)=delete |
ResolverFuture & | operator= (ResolverFuture &&)=delete |
A 'future' shared-state class for asynchronous name resolution that holds parameters and results of a call to getaddrinfo(), as performed by the run() method.
The run() method can be called from a worker thread and the results collected by the main thread using get() once the worker thread has signalled that it has finished. The signalling mechanism is outside the scope of this class (see GNet::FutureEvent).
Eg:
Definition at line 57 of file gresolverfuture.h.
using GNet::ResolverFuture::List = std::vector<Address> |
Definition at line 65 of file gresolverfuture.h.
GNet::ResolverFuture::ResolverFuture | ( | const std::string & | host, |
const std::string & | service, | ||
int | family, | ||
const Resolver::Config & | config | ||
) |
Constructor for resolving the given host and service names.
Definition at line 32 of file gresolverfuture.cpp.
GNet::ResolverFuture::~ResolverFuture | ( | ) |
Destructor.
Definition at line 54 of file gresolverfuture.cpp.
bool GNet::ResolverFuture::error | ( | ) | const |
Returns true if name resolution failed or no suitable address was returned.
Use after get().
Definition at line 159 of file gresolverfuture.cpp.
GNet::ResolverFuture::Result GNet::ResolverFuture::get | ( | ) |
Returns the resolved address after run() has completed.
Returns a default address if an error().
Definition at line 149 of file gresolverfuture.cpp.
void GNet::ResolverFuture::get | ( | List & | list | ) |
Returns by reference the resolved addresses after run() has completed by appending to the given list.
Appends nothing if an error().
Definition at line 141 of file gresolverfuture.cpp.
std::string GNet::ResolverFuture::reason | ( | ) | const |
Returns the reason for the error().
Precondition: error()
Definition at line 164 of file gresolverfuture.cpp.
|
noexcept |
Does the synchronous name resolution and stores the result.
Returns *this.
Definition at line 70 of file gresolverfuture.cpp.