12#ifndef OPENVPN_CLIENT_ASYNC_RESOLVE_ASIO_H
13#define OPENVPN_CLIENT_ASYNC_RESOLVE_ASIO_H
24template <
typename RESOLVER_TYPE>
43 const std::string &
host,
44 const std::string &
port)
51 openvpn_io::error_code error;
53 typename RESOLVER_TYPE::results_type results;
56 if (!self->is_detached())
58 self->post_callback(results, error);
67 detached.store(
true, std::memory_order_relaxed);
73 return detached.load(std::memory_order_relaxed);
77 openvpn_io::error_code error)
79 openvpn_io::post(
io_context, [self =
Ptr(
this), results, error]()
81 auto parent = self->parent;
82 if (!self->is_detached() &&
parent)
85 OPENVPN_ASYNC_HANDLER;
86 parent->resolve_callback(error, results);
ResolveThread(openvpn_io::io_context &io_context_arg, AsyncResolvable< RESOLVER_TYPE > *parent_arg, const std::string &host, const std::string &port)
AsyncResolvable< RESOLVER_TYPE > * parent
void post_callback(typename RESOLVER_TYPE::results_type results, openvpn_io::error_code error)
std::atomic< bool > detached
RCPtr< ResolveThread > Ptr
openvpn_io::io_context & io_context
RESOLVER_TYPE resolver_type
virtual ~AsyncResolvable()
void async_resolve_cancel()
AsyncResolvable(openvpn_io::io_context &io_context_arg)
void async_resolve_lock()
RCPtr< AsyncResolvable > Ptr
openvpn_io::io_context & io_context
typename RESOLVER_TYPE::results_type results_type
virtual void async_resolve_name(const std::string &host, const std::string &port)
virtual void resolve_callback(const openvpn_io::error_code &error, results_type results)=0
ResolveThread::Ptr resolve_thread
std::unique_ptr< AsioWork > asio_work
void reset() noexcept
Points this RCPtr<T> to nullptr safely.
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.