coreinit: Make OSReport and OSConsoleWrite thread-safe

This commit is contained in:
Exzap 2022-09-03 23:53:45 +02:00 committed by GitHub
parent d22901be1c
commit 8dd1688ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,11 +264,13 @@ namespace coreinit
return "Unknown";
}
std::mutex sCafeConsoleMutex;
void WriteCafeConsole(CafeLogType cafeLogType, const char* msg, sint32 len)
{
// once a line is full or \n is written it will be posted to log
std::unique_lock _l(sCafeConsoleMutex);
CafeLogBuffer& logBuffer = getLogBuffer(cafeLogType);
// once a line is full or \n is written it will be posted to log
auto flushLine = [](CafeLogBuffer& cafeLogBuffer, std::string_view cafeLogName) -> void
{
cemuLog_log(LogType::CoreinitLogging, "[{0}] {1}", cafeLogName, std::basic_string_view(cafeLogBuffer.lineBuffer.data(), cafeLogBuffer.lineLength));