Fix synchronization issue at thread start

If a newly started thread immediately exits then m_running would
immediately be set to false again and the caller would be stuck
waiting for m_running to become true forever.
Since a mutex for synchronizing startup already exists we can
simply move the while loop into it.

see also: #5134 which introduced m_start_finished_mutex
This commit is contained in:
sfan5 2022-04-30 16:04:19 +02:00
parent a55982e7f0
commit 1e7b5d6fdb

@ -121,12 +121,12 @@ bool Thread::start()
return false;
}
// Allow spawned thread to continue
m_start_finished_mutex.unlock();
while (!m_running)
sleep_ms(1);
// Allow spawned thread to continue
m_start_finished_mutex.unlock();
m_joinable = true;
return true;