Skip to content

Commit

Permalink
multithread
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyoko-Jeremie committed Aug 31, 2023
1 parent 36321c5 commit da1693e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/TcpRelayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void TcpRelayServer::stop() {

void TcpRelayServer::async_accept(boost::asio::ip::tcp::acceptor &sa) {
auto session = std::make_shared<TcpRelaySession>(
ex,
boost::asio::make_strand(ioc),
upstreamPool,
statisticsInfo->weak_from_this(),
configLoader->shared_from_this(),
Expand Down
7 changes: 5 additions & 2 deletions src/TcpRelayServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#endif

#include <boost/asio/any_io_executor.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <memory>
#include <string>
Expand All @@ -44,6 +45,7 @@ class TcpRelaySession;
class TcpRelayServer : public std::enable_shared_from_this<TcpRelayServer> {

boost::asio::any_io_executor ex;
boost::asio::io_context& ioc;
std::shared_ptr<ConfigLoader> configLoader;
std::shared_ptr<UpstreamPool> upstreamPool;
std::shared_ptr<AuthClientManager> authClientManager;
Expand All @@ -56,11 +58,12 @@ class TcpRelayServer : public std::enable_shared_from_this<TcpRelayServer> {
std::shared_ptr<boost::asio::steady_timer> speedCalcTimer;
public:
TcpRelayServer(
boost::asio::any_io_executor ex,
boost::asio::io_context& ioc,
std::shared_ptr<ConfigLoader> configLoader,
std::shared_ptr<UpstreamPool> upstreamPool,
std::shared_ptr<AuthClientManager> authClientManager
) : ex(ex),
) : ioc(ioc),
ex(boost::asio::make_strand(ioc)),
configLoader(std::move(configLoader)),
upstreamPool(std::move(upstreamPool)),
authClientManager(std::move(authClientManager)),
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int main(int argc, const char *argv[]) {
auto upstreamPool = std::make_shared<UpstreamPool>(boost::asio::make_strand(ioc), tcpTest, connectTestHttps);
upstreamPool->setConfig(configLoader);

auto tcpRelay = std::make_shared<TcpRelayServer>(boost::asio::make_strand(ioc), configLoader, upstreamPool, authClientManager);
auto tcpRelay = std::make_shared<TcpRelayServer>(ioc, configLoader, upstreamPool, authClientManager);
auto stateMonitor = std::make_shared<StateMonitorServer>(
boost::asio::make_strand(ioc), configLoader, upstreamPool, tcpRelay);

Expand Down

0 comments on commit da1693e

Please sign in to comment.