From 1ac6c9f9c21e94b0d3934f3fef2402f86824c511 Mon Sep 17 00:00:00 2001 From: gabime Date: Wed, 8 May 2019 17:17:11 +0300 Subject: [PATCH] clang-format static-lib --- include/spdlog/common.h | 1 - include/spdlog/details/periodic_worker.h | 2 - include/spdlog/details/thread_pool.h | 2 - include/spdlog/impl/periodic_worker.cpp | 1 - include/spdlog/impl/thread_pool.cpp | 62 ++++++++++++------------ 5 files changed, 30 insertions(+), 38 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 0bcd03f5..7af05411 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -23,7 +23,6 @@ #include "spdlog/fmt/fmt.h" - #ifdef SPDLOG_STATIC_LIB #define SPDLOG_INLINE #else diff --git a/include/spdlog/details/periodic_worker.h b/include/spdlog/details/periodic_worker.h index 9e9cd731..03e611aa 100644 --- a/include/spdlog/details/periodic_worker.h +++ b/include/spdlog/details/periodic_worker.h @@ -29,7 +29,6 @@ public: // stop the worker thread and join it ~periodic_worker(); - private: bool active_; std::thread worker_thread_; @@ -39,7 +38,6 @@ private: } // namespace details } // namespace spdlog - #ifndef SPDLOG_STATIC_LIB #include "spdlog/impl/periodic_worker.cpp" #endif diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index 80c2d11f..a872c303 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -127,7 +127,6 @@ public: // message all threads to terminate gracefully join them ~thread_pool(); - thread_pool(const thread_pool &) = delete; thread_pool &operator=(thread_pool &&) = delete; @@ -135,7 +134,6 @@ public: void post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy); size_t overrun_counter(); - private: q_type q_; diff --git a/include/spdlog/impl/periodic_worker.cpp b/include/spdlog/impl/periodic_worker.cpp index 6c0e997d..33f82ae9 100644 --- a/include/spdlog/impl/periodic_worker.cpp +++ b/include/spdlog/impl/periodic_worker.cpp @@ -42,4 +42,3 @@ SPDLOG_INLINE spdlog::details::periodic_worker::~periodic_worker() worker_thread_.join(); } } - diff --git a/include/spdlog/impl/thread_pool.cpp b/include/spdlog/impl/thread_pool.cpp index 66c26fd6..e97c30a5 100644 --- a/include/spdlog/impl/thread_pool.cpp +++ b/include/spdlog/impl/thread_pool.cpp @@ -8,19 +8,20 @@ template class spdlog::details::mpmc_blocking_queue; #include "spdlog/common.h" -SPDLOG_INLINE spdlog::details::thread_pool::thread_pool(size_t q_max_items, size_t threads_n) : q_(q_max_items) +SPDLOG_INLINE spdlog::details::thread_pool::thread_pool(size_t q_max_items, size_t threads_n) + : q_(q_max_items) { - // std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << - // "\tthreads_n: " << threads_n << std::endl; - if (threads_n == 0 || threads_n > 1000) - { - throw spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid " - "range is 1-1000)"); - } - for (size_t i = 0; i < threads_n; i++) - { - threads_.emplace_back(&thread_pool::worker_loop_, this); - } + // std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << + // "\tthreads_n: " << threads_n << std::endl; + if (threads_n == 0 || threads_n > 1000) + { + throw spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid " + "range is 1-1000)"); + } + for (size_t i = 0; i < threads_n; i++) + { + threads_.emplace_back(&thread_pool::worker_loop_, this); + } } // message all threads to terminate gracefully join them @@ -43,7 +44,8 @@ SPDLOG_INLINE spdlog::details::thread_pool::~thread_pool() } } -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 spdlog::details::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); @@ -90,27 +92,23 @@ bool SPDLOG_INLINE spdlog::details::thread_pool::process_next_msg_() switch (incoming_async_msg.msg_type) { - case async_msg_type::log: - { - auto msg = incoming_async_msg.to_log_msg(); - incoming_async_msg.worker_ptr->backend_log_(msg); - return true; - } - case async_msg_type::flush: - { - incoming_async_msg.worker_ptr->backend_flush_(); - return true; - } + case async_msg_type::log: + { + auto msg = incoming_async_msg.to_log_msg(); + incoming_async_msg.worker_ptr->backend_log_(msg); + return true; + } + case async_msg_type::flush: + { + incoming_async_msg.worker_ptr->backend_flush_(); + return true; + } - case async_msg_type::terminate: - { - return false; - } + case async_msg_type::terminate: + { + return false; + } } assert(false && "Unexpected async_msg_type"); return true; } - - - -