Added thread callback option to thread_pool
This commit is contained in:
parent
220608e52a
commit
b12c19162b
@ -18,8 +18,10 @@
|
|||||||
#include "spdlog/details/registry.h"
|
#include "spdlog/details/registry.h"
|
||||||
#include "spdlog/details/thread_pool.h"
|
#include "spdlog/details/thread_pool.h"
|
||||||
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace spdlog {
|
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)...);
|
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.
|
// set global thread pool.
|
||||||
inline void init_thread_pool(size_t q_size, size_t thread_count)
|
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);
|
init_thread_pool(q_size, thread_count, []{});
|
||||||
details::registry::instance().set_tp(std::move(tp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the global thread pool.
|
// get the global thread pool.
|
||||||
|
Loading…
Reference in New Issue
Block a user