rcpp_framework/libs/brynet/net/AsyncConnector.hpp

33 lines
700 B
C++
Raw Normal View History

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