31 log_clock::time_point
time;
46 #if defined(_MSC_VER) && _MSC_VER <= 1800 50 thread_id(other.thread_id),
54 worker_ptr(
std::move(other.worker_ptr))
60 msg_type = other.msg_type;
63 thread_id = other.thread_id;
64 raw = std::move(other.raw);
65 msg_id = other.msg_id;
66 source = other.source;
67 worker_ptr = std::move(other.worker_ptr);
70 #else // (_MSC_VER) && _MSC_VER <= 1800 80 , thread_id(m.thread_id)
83 , worker_ptr(
std::move(worker))
95 , worker_ptr(
std::move(worker))
129 if (threads_n == 0 || threads_n > 1000)
131 throw spdlog_ex(
"spdlog::thread_pool(): invalid threads_n param (valid " 134 for (
size_t i = 0; i < threads_n; i++)
136 threads_.emplace_back(&thread_pool::worker_loop_,
this);
145 for (
size_t i = 0; i < threads_.size(); i++)
150 for (
auto &t : threads_)
166 post_async_msg_(std::move(async_m), overflow_policy);
176 return q_.overrun_counter();
182 std::vector<std::thread> threads_;
188 q_.
enqueue(std::move(new_msg));
198 while (process_next_msg_()) {};
204 bool process_next_msg_()
207 bool dequeued = q_.
dequeue_for(incoming_async_msg, std::chrono::seconds(10));
213 switch (incoming_async_msg.
msg_type)
218 incoming_async_msg.
worker_ptr->backend_log_(msg);
223 incoming_async_msg.
worker_ptr->backend_flush_();
232 assert(
false &&
"Unexpected async_msg_type");
thread_pool(size_t q_max_items, size_t threads_n)
void post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy)
void enqueue_nowait(T &&item)
async_msg(async_logger_ptr &&worker, async_msg_type the_type, details::log_msg &m)
log_clock::time_point time
async_logger_ptr worker_ptr
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration)
size_t thread_id() noexcept
std::shared_ptr< spdlog::details::thread_pool > thread_pool()
async_msg(async_msg_type the_type)
void append_string_view(spdlog::string_view_t view, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
fmt::basic_memory_buffer< char, 176 > raw
fmt::string_view string_view_t
std::shared_ptr< spdlog::async_logger > async_logger_ptr
const string_view_t payload
async_msg(async_logger_ptr &&worker, async_msg_type the_type)
void post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy)
log_clock::time_point time