diff --git a/include/spdlog/async.h b/include/spdlog/async.h index 0c5e07ae..70f6c3fb 100644 --- a/include/spdlog/async.h +++ b/include/spdlog/async.h @@ -18,8 +18,10 @@ #include "spdlog/details/registry.h" #include "spdlog/details/thread_pool.h" + #include #include +#include namespace spdlog { @@ -69,11 +71,17 @@ inline std::shared_ptr create_async_nb(std::string logger_name, return async_factory_nonblock::create(std::move(logger_name), std::forward(sink_args)...); } +// set global thread pool. +inline void init_thread_pool(size_t q_size, size_t thread_count, std::function on_thread_start) +{ + auto tp = std::make_shared(q_size, thread_count, on_thread_start); + details::registry::instance().set_tp(std::move(tp)); +} + // set global thread pool. inline void init_thread_pool(size_t q_size, size_t thread_count) { - auto tp = std::make_shared(q_size, thread_count); - details::registry::instance().set_tp(std::move(tp)); + init_thread_pool(q_size, thread_count, []{}); } // get the global thread pool.