From 57756a5f16cc2fdfca5ef8b04c73042a37355365 Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Thu, 5 Feb 2026 13:52:11 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=8B=9C=EA=B7=B8=EB=84=90=20?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=99=80=20=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/NetworkService.h | 5 +++-- server/NetworkService.cpp | 6 ++++-- server/main.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/NetworkService.h b/include/NetworkService.h index 4a3d27a..a187b7b 100644 --- a/include/NetworkService.h +++ b/include/NetworkService.h @@ -8,7 +8,8 @@ using boost::asio::ip::tcp; class NetworkService { public: - NetworkService(uint16_t port, int threadCount); + NetworkService(boost::asio::io_context &io_context, uint16_t port, + int threadCount); ~NetworkService(); void Run(); @@ -17,7 +18,7 @@ public: private: void DoAccept(); - boost::asio::io_context io_context_; + boost::asio::io_context &io_context_; std::vector threads_; tcp::acceptor acceptor_; boost::asio::executor_work_guard diff --git a/server/NetworkService.cpp b/server/NetworkService.cpp index 2a13784..f126266 100644 --- a/server/NetworkService.cpp +++ b/server/NetworkService.cpp @@ -2,8 +2,10 @@ #include "Logger.h" #include "Session.h" -NetworkService::NetworkService(uint16_t port, int threadCount) - : acceptor_(io_context_, tcp::endpoint(tcp::v4(), port)), +NetworkService::NetworkService(boost::asio::io_context &io_context, + uint16_t port, int threadCount) + : io_context_(io_context), + acceptor_(io_context_, tcp::endpoint(tcp::v4(), port)), work_guard_(boost::asio::make_work_guard(io_context_)) { threads_.reserve(threadCount); for (int i = 0; i < threadCount; ++i) { diff --git a/server/main.cpp b/server/main.cpp index 3270f08..9abedd4 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -32,7 +32,7 @@ int main() { return 1; } - NetworkService server(port, threadCount); + NetworkService server(main_context, port, threadCount); server.Run(); boost::asio::signal_set signals(main_context, SIGINT, SIGTERM);