From 3bdae1a05f1bbf5848e2213aca74e5154ffe15a0 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 16 May 2022 21:41:15 +0200 Subject: [PATCH] Use mutex instead --- r5dev/public/utility.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/r5dev/public/utility.cpp b/r5dev/public/utility.cpp index 2b086537..ec6c1dbf 100644 --- a/r5dev/public/utility.cpp +++ b/r5dev/public/utility.cpp @@ -148,13 +148,11 @@ void PrintLastError(void) void HexDump(const char* szHeader, const char* szLogger, const void* pData, int nSize) { static unsigned char szAscii[17] = {}; + static std::mutex m; static std::atomic i = {}, j = {}, k = {}; static std::shared_ptr logger = spdlog::get("default_logger"); - // Loop until the function returned to the first caller. - while (k == 1) { /*Sleep(75);*/ } - - k = 1; + m.lock(); szAscii[16] = '\0'; if (szLogger) @@ -229,7 +227,7 @@ void HexDump(const char* szHeader, const char* szLogger, const void* pData, int } } } - k = 0; + m.unlock(); /////////////////////////////////////////////////////////////////////////// }