From e9bbb68829e972df2e458aa5beec0568d4737f02 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 29 Dec 2018 13:27:21 +0100 Subject: compat/spinlock: implement and use it --- gui/init.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'gui') diff --git a/gui/init.cpp b/gui/init.cpp index 9e6b79dc..2b84beef 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -95,7 +95,8 @@ static void set_qt_style() #ifdef _WIN32 -#include +#include "compat/spinlock.hpp" + #include #include #include @@ -108,14 +109,10 @@ static void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QS if (IsDebuggerPresent()) { static std::atomic_flag lock = ATOMIC_FLAG_INIT; - - while (!lock.test_and_set()) - (void)0; + spinlock_guard l(lock); OutputDebugStringW(str); OutputDebugStringW(L"\n"); - - lock.clear(); } else { -- cgit v1.2.3