5#include <restinio/asio_include.hpp>
7#include <restinio/exception.hpp>
16
17
18
19
20
21
22
23
24
37
38
39
40
41
42
43
44
45
54 asio_ns::io_context & ioctx )
78
79
80
81
82
83
84
85
86
87template<
typename Io_Context_Holder >
94 template<
typename... Io_Context_Holder_Ctor_Args >
97 std::size_t pool_size,
99 Io_Context_Holder_Ctor_Args && ...ioctx_holder_args )
101 std::forward<Io_Context_Holder_Ctor_Args>(ioctx_holder_args)... }
122 "io_context_with_thread_pool is already started" };
132 std::thread{ [
this] {
133 auto work{ asio_ns::make_work_guard(
134 m_ioctx_holder.io_context() ) };
136 m_ioctx_holder.io_context().run();
144 catch(
const std::exception & )
147 for(
auto & t : m_pool )
177 for(
auto & t : m_pool )
187 asio_ns::io_context &
Exception class for all exceptions thrown by RESTinio.
exception_t(const char *err)
A class for holding a reference to external Asio's io_context.
external_io_context_for_thread_pool_t(asio_ns::io_context &ioctx)
Initializing constructor.
asio_ns::io_context & m_ioctx
auto & io_context() noexcept
Get access to io_context object.
asio_ns::io_context & io_context() noexcept
bool started() const noexcept
std::vector< std::thread > m_pool
~ioctx_on_thread_pool_t()
ioctx_on_thread_pool_t(const ioctx_on_thread_pool_t &)=delete
ioctx_on_thread_pool_t(ioctx_on_thread_pool_t &&)=delete
Io_Context_Holder m_ioctx_holder
ioctx_on_thread_pool_t(std::size_t pool_size, Io_Context_Holder_Ctor_Args &&...ioctx_holder_args)
A class for holding actual instance of Asio's io_context.
auto & io_context() noexcept
Get access to io_context object.
own_io_context_for_thread_pool_t()=default
asio_ns::io_context m_ioctx
std::size_t ensure_pool_size_non_zero(std::size_t pool_size)