Use stop token in PopWait and check if entry filename is nullptr before logging.

This commit is contained in:
Levi Behunin
2021-10-21 17:58:49 -06:00
parent 3e5d69b522
commit 95b688a128

View File

@@ -223,15 +223,17 @@ private:
} }
void StartBackendThread() { void StartBackendThread() {
backend_thread{std::thread([this] { backend_thread = std::thread([this] {
Common::SetCurrentThreadName("yuzu:Log"); Common::SetCurrentThreadName("yuzu:Log");
Entry entry; Entry entry;
const auto write_logs = [this, &entry]() { const auto write_logs = [this, &entry]() {
ForEachBackend([&entry](Backend& backend) { backend.Write(entry); }); ForEachBackend([&entry](Backend& backend) { backend.Write(entry); });
}; };
while (!stop.stop_requested()) { while (!stop.stop_requested()) {
entry = message_queue.PopWait(); entry = message_queue.PopWait(stop.get_token());
write_logs(); if (entry.filename != nullptr) {
write_logs();
}
} }
// Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a
// case where a system is repeatedly spamming logs even on close. // case where a system is repeatedly spamming logs even on close.
@@ -239,7 +241,7 @@ private:
while (max_logs_to_write-- && message_queue.Pop(entry)) { while (max_logs_to_write-- && message_queue.Pop(entry)) {
write_logs(); write_logs();
} }
})}; });
} }
void StopBackendThread() { void StopBackendThread() {