ISO/USB: fix potential race condition

This commit is contained in:
Tillmann Karras 2020-08-02 23:20:33 +01:00
parent a161e58591
commit 1f4b9adbf5
1 changed files with 1 additions and 2 deletions

View File

@ -179,9 +179,8 @@ void USBHost::StartThreads()
if (Core::WantsDeterminism()) if (Core::WantsDeterminism())
return; return;
if (!m_scan_thread_running.IsSet()) if (m_scan_thread_running.TestAndSet())
{ {
m_scan_thread_running.Set();
m_scan_thread = std::thread([this] { m_scan_thread = std::thread([this] {
Common::SetCurrentThreadName("USB Scan Thread"); Common::SetCurrentThreadName("USB Scan Thread");
while (m_scan_thread_running.IsSet()) while (m_scan_thread_running.IsSet())