|
|
@ -11,7 +11,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace spdlog {
|
|
|
|
namespace spdlog {
|
|
|
|
namespace details {
|
|
|
|
namespace details {
|
|
|
|
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n, std::function<void()> on_thread_start)
|
|
|
|
: q_(q_max_items)
|
|
|
|
: q_(q_max_items)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (threads_n == 0 || threads_n > 1000)
|
|
|
|
if (threads_n == 0 || threads_n > 1000)
|
|
|
@ -21,8 +22,18 @@ SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < threads_n; i++)
|
|
|
|
for (size_t i = 0; i < threads_n; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
threads_.emplace_back(&thread_pool::worker_loop_, this);
|
|
|
|
threads_.emplace_back([this, on_thread_start]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
on_thread_start();
|
|
|
|
|
|
|
|
this->thread_pool::worker_loop_();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n):
|
|
|
|
|
|
|
|
thread_pool(q_max_items, threads_n, []{})
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// message all threads to terminate gracefully join them
|
|
|
|
// message all threads to terminate gracefully join them
|
|
|
|