Added thread callback option to thread_pool
This commit is contained in:
		@@ -18,8 +18,10 @@
 | 
			
		||||
#include "spdlog/details/registry.h"
 | 
			
		||||
#include "spdlog/details/thread_pool.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <mutex>
 | 
			
		||||
#include <functional>
 | 
			
		||||
 | 
			
		||||
namespace spdlog {
 | 
			
		||||
 | 
			
		||||
@@ -69,11 +71,17 @@ inline std::shared_ptr<spdlog::logger> create_async_nb(std::string logger_name,
 | 
			
		||||
    return async_factory_nonblock::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// set global thread pool.
 | 
			
		||||
inline void init_thread_pool(size_t q_size, size_t thread_count, std::function<void()> on_thread_start)
 | 
			
		||||
{
 | 
			
		||||
    auto tp = std::make_shared<details::thread_pool>(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<details::thread_pool>(q_size, thread_count);
 | 
			
		||||
    details::registry::instance().set_tp(std::move(tp));
 | 
			
		||||
    init_thread_pool(q_size, thread_count, []{});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// get the global thread pool.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user