From 822f972842326339af89eedb0277ebe5560a7c1f Mon Sep 17 00:00:00 2001 From: bergen Date: Thu, 9 Jun 2022 19:39:57 +0800 Subject: [PATCH 1/2] update --- include/spdlog/details/circular_q.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/spdlog/details/circular_q.h b/include/spdlog/details/circular_q.h index 1f2712e7..e4fd5fd4 100644 --- a/include/spdlog/details/circular_q.h +++ b/include/spdlog/details/circular_q.h @@ -121,6 +121,11 @@ public: return overrun_counter_; } + void reset_overrun_counter() + { + overrun_counter_ = 0; + } + private: // copy from other&& and reset it to disabled state void copy_moveable(circular_q &&other) SPDLOG_NOEXCEPT From 1f608a81e86f6e1b64f67f17db0f027399f3b0bb Mon Sep 17 00:00:00 2001 From: bergen Date: Thu, 9 Jun 2022 19:45:40 +0800 Subject: [PATCH 2/2] add overrun reset function --- include/spdlog/details/mpmc_blocking_q.h | 6 ++++++ include/spdlog/details/thread_pool-inl.h | 5 +++++ include/spdlog/details/thread_pool.h | 1 + 3 files changed, 12 insertions(+) diff --git a/include/spdlog/details/mpmc_blocking_q.h b/include/spdlog/details/mpmc_blocking_q.h index b70483e5..785180c1 100644 --- a/include/spdlog/details/mpmc_blocking_q.h +++ b/include/spdlog/details/mpmc_blocking_q.h @@ -116,6 +116,12 @@ public: return q_.size(); } + void reset_overrun_counter() + { + std::unique_lock lock(queue_mutex_); + q_.reset_overrun_counter(); + } + private: std::mutex queue_mutex_; std::condition_variable push_cv_; diff --git a/include/spdlog/details/thread_pool-inl.h b/include/spdlog/details/thread_pool-inl.h index e4b3e1c4..369f30fe 100644 --- a/include/spdlog/details/thread_pool-inl.h +++ b/include/spdlog/details/thread_pool-inl.h @@ -75,6 +75,11 @@ size_t SPDLOG_INLINE thread_pool::overrun_counter() return q_.overrun_counter(); } +void SPDLOG_INLINE thread_pool::reset_overrun_counter() +{ + q_.reset_overrun_counter(); +} + size_t SPDLOG_INLINE thread_pool::queue_size() { return q_.size(); diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index 63738b5b..52c569b8 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -97,6 +97,7 @@ public: void post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy); void post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy); size_t overrun_counter(); + void reset_overrun_counter(); size_t queue_size(); private: