From bea449747effe6a9280056a18488c62419fbde77 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Tue, 1 Dec 2026 16:46:28 +0100 Subject: Actually run multiple threads --- server/src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/src/main.cpp b/server/src/main.cpp index 6e13c82..9d576a2 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -137,7 +137,8 @@ auto server_main(routemon::log::logger& l, routemon::config::app config) }; auto lsel = routemon::locale::selector{locales, default_locale}; - auto ioc = net::io_context{2 /* concurrency hint */}; + auto const nthread = 2uz; + auto ioc = net::io_context{nthread /* concurrency hint */}; auto dbc = std::shared_ptr{}; try @@ -216,9 +217,13 @@ auto server_main(routemon::log::logger& l, routemon::config::app config) }, net::detached); - ioc.run(); + auto threads = std::vector{nthread}; + for (auto& thread : threads) + thread = std::thread{[&ioc]() { ioc.run(); }}; + for (auto& thread : threads) + thread.join(); - l.error("I/O context stopped"); + l.error("I/O contexts stopped"); return exit_status::failure; } -- cgit v1.3.1