3#include <boost/asio/executor_work_guard.hpp>
4#include <boost/asio/io_context.hpp>
5#include <boost/asio/use_future.hpp>
6#include <spdlog/logger.h>
12namespace malloy::detail
28 std::shared_ptr<spdlog::logger>
logger;
34 throw std::logic_error{
"invalid config: logger is null"};
37 throw std::logic_error{
"invalid config: cannot have 0 threads"};
41 template<std::movable T>
53 m_io_ctx{std::move(ioc)},
54 m_workguard{m_io_ctx->get_executor()},
55 m_ctrl{std::move(ctrl)}
60 m_io_threads.emplace_back(
61 [m_io_ctx = m_io_ctx.get()] {
68 cfg.
logger->debug(
"starting i/o context.");
94 for (
auto& thread : m_io_threads)
105 throw std::logic_error{
"attempt to call run() on moved from run_result_t"};
112 using workguard_t = boost::asio::executor_work_guard<boost::asio::io_context::executor_type>;
114 std::unique_ptr<boost::asio::io_context> m_io_ctx;
115 workguard_t m_workguard;
116 std::vector<std::thread> m_io_threads;
Definition: controller_run_result.hpp:43
controller_run_result(const controller_config &cfg, T ctrl, std::unique_ptr< boost::asio::io_context > ioc)
Definition: controller_run_result.hpp:52
void run()
Block until all queued async actions completed.
Definition: controller_run_result.hpp:102
Definition: controller_run_result.hpp:19
std::shared_ptr< spdlog::logger > logger
Definition: controller_run_result.hpp:28
std::size_t num_threads
Definition: controller_run_result.hpp:23