mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
clang format and SPLDOG_HEADER_ONLY macro
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
|
||||
#include "spdlog/common.h"
|
||||
|
||||
SPDLOG_INLINE spdlog::details::thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
|
||||
: q_(q_max_items)
|
||||
{
|
||||
if (threads_n == 0 || threads_n > 1000)
|
||||
@@ -20,7 +22,7 @@ SPDLOG_INLINE spdlog::details::thread_pool::thread_pool(size_t q_max_items, size
|
||||
}
|
||||
|
||||
// message all threads to terminate gracefully join them
|
||||
SPDLOG_INLINE spdlog::details::thread_pool::~thread_pool()
|
||||
SPDLOG_INLINE thread_pool::~thread_pool()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -35,28 +37,26 @@ SPDLOG_INLINE spdlog::details::thread_pool::~thread_pool()
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
{}
|
||||
}
|
||||
|
||||
void SPDLOG_INLINE spdlog::details::thread_pool::post_log(
|
||||
async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy)
|
||||
void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy)
|
||||
{
|
||||
async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg);
|
||||
post_async_msg_(std::move(async_m), overflow_policy);
|
||||
}
|
||||
|
||||
void SPDLOG_INLINE spdlog::details::thread_pool::post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy)
|
||||
void SPDLOG_INLINE thread_pool::post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy)
|
||||
{
|
||||
post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), overflow_policy);
|
||||
}
|
||||
|
||||
size_t SPDLOG_INLINE spdlog::details::thread_pool::overrun_counter()
|
||||
size_t SPDLOG_INLINE thread_pool::overrun_counter()
|
||||
{
|
||||
return q_.overrun_counter();
|
||||
}
|
||||
|
||||
void SPDLOG_INLINE spdlog::details::thread_pool::post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy)
|
||||
void SPDLOG_INLINE thread_pool::post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy)
|
||||
{
|
||||
if (overflow_policy == async_overflow_policy::block)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ void SPDLOG_INLINE spdlog::details::thread_pool::post_async_msg_(async_msg &&new
|
||||
}
|
||||
}
|
||||
|
||||
void SPDLOG_INLINE spdlog::details::thread_pool::worker_loop_()
|
||||
void SPDLOG_INLINE thread_pool::worker_loop_()
|
||||
{
|
||||
while (process_next_msg_()) {};
|
||||
}
|
||||
@@ -76,7 +76,7 @@ void SPDLOG_INLINE spdlog::details::thread_pool::worker_loop_()
|
||||
// process next message in the queue
|
||||
// return true if this thread should still be active (while no terminate msg
|
||||
// was received)
|
||||
bool SPDLOG_INLINE spdlog::details::thread_pool::process_next_msg_()
|
||||
bool SPDLOG_INLINE thread_pool::process_next_msg_()
|
||||
{
|
||||
async_msg incoming_async_msg;
|
||||
bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10));
|
||||
@@ -107,3 +107,6 @@ bool SPDLOG_INLINE spdlog::details::thread_pool::process_next_msg_()
|
||||
assert(false && "Unexpected async_msg_type");
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
||||
Reference in New Issue
Block a user