1
1
Fork 0
forked from suyu/suyu

Logging: Don't lock the queue for the duration of the write

This commit is contained in:
James Rowe 2018-07-14 11:57:13 -06:00
parent b30c5370b1
commit 6daebaaa57

View file

@ -83,8 +83,10 @@ private:
}
};
while (true) {
std::unique_lock<std::mutex> lock(message_mutex);
message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
{
std::unique_lock<std::mutex> lock(message_mutex);
message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
}
if (!running) {
break;
}
@ -282,4 +284,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
Impl::Instance().PushEntry(std::move(entry));
}
} // namespace Log
} // namespace Log