const auto thread_pools_map = setup_thread_pools(config); // set up loggers, setting the respective sinks and patterns setup_loggers(config, sinks_map, patterns_map, thread_pools_map);
thread_pools_map has contain std::shared_ptr, out of scope, thread_pool will be released, but logger still in use;logger has a thread_pool variable, the thread_pool variable is std::weak_ptr, that do not own raw ptr.
const auto thread_pools_map = setup_thread_pools(config); // set up loggers, setting the respective sinks and patterns setup_loggers(config, sinks_map, patterns_map, thread_pools_map);
thread_pools_map has contain std::shared_ptr, out of scope, thread_pool will be released, but logger still in use;logger has a thread_pool variable, the thread_pool variable is std::weak_ptr, that do not own raw ptr.
spdlog define
SPDLOG_INLINE spdlog::async_logger::async_logger( std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy) : async_logger(std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) {}
logger write log, will throw exception。
"async log: thread pool doesn't exist anymore"