From f2f6f253ec60c03666c578957f5aeebaf146cdad Mon Sep 17 00:00:00 2001 From: sha512sum Date: Tue, 19 Mar 2024 17:19:11 +0000 Subject: [PATCH] Use std::thread instead std::jthread(For builds with libc++) --- include/cserver/engine/basic/task_processor.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/cserver/engine/basic/task_processor.hpp b/include/cserver/engine/basic/task_processor.hpp index fa979c6..d41ca47 100644 --- a/include/cserver/engine/basic/task_processor.hpp +++ b/include/cserver/engine/basic/task_processor.hpp @@ -8,7 +8,7 @@ namespace cserver::engine::basic { template struct TaskProcessor { boost::asio::io_context ioContext; - std::array pool; + std::array pool; static constexpr utempl::ConstexprString kName = "basicTaskProcessor"; inline constexpr TaskProcessor(auto, auto&) : ioContext{}, @@ -23,10 +23,15 @@ struct TaskProcessor { return {}; }); }; + inline constexpr ~TaskProcessor() { + for(auto& thread : this->pool) { + thread.join(); + }; + }; inline auto Run() { for(auto& thread : this->pool) { - thread = std::jthread([&]{ + thread = std::thread([&]{ boost::asio::executor_work_guardioContext.get_executor())> guard{this->ioContext.get_executor()}; this->ioContext.run(); });