rcpp_framework/libs/brynet/net/AsyncConnector.hpp

42 lines
908 B
C++
Raw Normal View History

2020-11-24 15:41:18 +01:00
#pragma once
#include <brynet/net/detail/ConnectorDetail.hpp>
namespace brynet { namespace net {
2021-04-30 16:10:14 +02:00
using ConnectOption = detail::ConnectOption;
class AsyncConnector : public detail::AsyncConnectorDetail,
public std::enable_shared_from_this<AsyncConnector>
{
public:
using Ptr = std::shared_ptr<AsyncConnector>;
void startWorkerThread()
2020-11-24 15:41:18 +01:00
{
2021-04-30 16:10:14 +02:00
detail::AsyncConnectorDetail::startWorkerThread();
}
2020-11-24 15:41:18 +01:00
2021-04-30 16:10:14 +02:00
void stopWorkerThread()
2020-11-24 15:41:18 +01:00
{
2021-04-30 16:10:14 +02:00
detail::AsyncConnectorDetail::stopWorkerThread();
}
2020-11-24 15:41:18 +01:00
2021-04-30 16:10:14 +02:00
void asyncConnect(const ConnectOption& option)
{
detail::AsyncConnectorDetail::asyncConnect(option);
}
2020-11-24 15:41:18 +01:00
2021-04-30 16:10:14 +02:00
static Ptr Create()
{
class make_shared_enabler : public AsyncConnector
2020-11-24 15:41:18 +01:00
{
2021-04-30 16:10:14 +02:00
};
return std::make_shared<make_shared_enabler>();
}
2020-11-24 15:41:18 +01:00
2021-04-30 16:10:14 +02:00
private:
AsyncConnector() = default;
};
2020-11-24 15:41:18 +01:00
2021-04-30 16:10:14 +02:00
}}// namespace brynet::net