|
@@ -24,15 +24,14 @@ rtc::LogCounter::LogCounter(plog::Severity severity, const std::string &text, st
|
|
|
rtc::LogCounter& rtc::LogCounter::operator++(int) {
|
|
|
std::lock_guard lock(mutex);
|
|
|
count++;
|
|
|
- if (!future) {
|
|
|
- future = ThreadPool::Instance().schedule(duration, [](std::weak_ptr<LogCounter> ptr) {
|
|
|
+ if (count == 1) {
|
|
|
+ ThreadPool::Instance().schedule(duration, [](std::weak_ptr<LogCounter> ptr) {
|
|
|
if (auto log = ptr.lock()) {
|
|
|
int countCopy;
|
|
|
{
|
|
|
std::lock_guard lock(log->mutex);
|
|
|
countCopy = log->count;
|
|
|
log->count = 0;
|
|
|
- log->future = std::nullopt;
|
|
|
}
|
|
|
PLOG(log->severity) << log->text << ": " << countCopy << " (over "
|
|
|
<< std::chrono::duration_cast<std::chrono::seconds>(log->duration).count() << " seconds)";
|