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>
Public Types | |
using | Pair = std::pair< Address, std::string > |
using | List = std::vector< Address > |
Public Member Functions | |
ResolverFuture (const std::string &host, const std::string &service, int family, bool dgram, bool for_async_hint=false) | |
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... | |
Pair | get () |
Returns the resolved address/name pair after run() has completed. More... | |
void | get (List &) |
Returns 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 | |
void | operator= (const ResolverFuture &)=delete |
void | 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 56 of file gresolverfuture.h.
using GNet::ResolverFuture::List = std::vector<Address> |
Definition at line 60 of file gresolverfuture.h.
using GNet::ResolverFuture::Pair = std::pair<Address,std::string> |
Definition at line 59 of file gresolverfuture.h.
GNet::ResolverFuture::ResolverFuture | ( | const std::string & | host, |
const std::string & | service, | ||
int | family, | ||
bool | dgram, | ||
bool | for_async_hint = false |
||
) |
Constructor for resolving the given host and service names.
Definition at line 30 of file gresolverfuture.cpp.
GNet::ResolverFuture::~ResolverFuture | ( | ) |
Destructor.
Definition at line 51 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 146 of file gresolverfuture.cpp.
GNet::ResolverFuture::Pair GNet::ResolverFuture::get | ( | ) |
Returns the resolved address/name pair after run() has completed.
Returns default values if an error().
Definition at line 136 of file gresolverfuture.cpp.
void GNet::ResolverFuture::get | ( | List & | list | ) |
Returns the resolved addresses after run() has completed by appending to the given list.
Appends nothing if an error().
Definition at line 128 of file gresolverfuture.cpp.
std::string GNet::ResolverFuture::reason | ( | ) | const |
Returns the reason for the error().
Precondition: error()
Definition at line 151 of file gresolverfuture.cpp.
|
noexcept |
Does the synchronous name resolution and stores the result.
Returns *this.
Definition at line 57 of file gresolverfuture.cpp.