mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
increment counter every time we overrid a message in async mode.
This commit is contained in:
@@ -31,6 +31,7 @@ public:
|
||||
if (tail_ == head_) // overrun last item if full
|
||||
{
|
||||
head_ = (head_ + 1) % max_items_;
|
||||
++overrun_counter_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +54,19 @@ public:
|
||||
return ((tail_ + 1) % max_items_) == head_;
|
||||
}
|
||||
|
||||
int overrun_counter() const
|
||||
{
|
||||
return overrun_counter_;
|
||||
}
|
||||
|
||||
private:
|
||||
size_t max_items_;
|
||||
typename std::vector<T>::size_type head_ = 0;
|
||||
typename std::vector<T>::size_type tail_ = 0;
|
||||
|
||||
std::vector<T> v_;
|
||||
|
||||
int overrun_counter_ = 0;
|
||||
};
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@@ -30,6 +30,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
int overrun_counter() const
|
||||
{
|
||||
return q_.overrun_counter();
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
// try to enqueue and block if no room left
|
||||
void enqueue(T &&item)
|
||||
|
@@ -157,6 +157,11 @@ public:
|
||||
post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), overflow_policy);
|
||||
}
|
||||
|
||||
int overrun_counter() const
|
||||
{
|
||||
return q_.overrun_counter();
|
||||
}
|
||||
|
||||
private:
|
||||
q_type q_;
|
||||
|
||||
|
Reference in New Issue
Block a user