Thread::~Thread()
{
kill();
+
+ // Make sure start finished mutex is unlocked before it's destroyed
+ m_start_finished_mutex.try_lock();
+ m_start_finished_mutex.unlock();
+
}
m_request_stop = false;
+ // The mutex may already be locked if the thread is being restarted
+ m_start_finished_mutex.try_lock();
+
#if USE_CPP11_THREADS
try {
#endif
+ // Allow spawned thread to continue
+ m_start_finished_mutex.unlock();
+
while (!m_running)
sleep_ms(1);
g_logger.registerThread(thr->m_name);
thr->m_running = true;
+ // Wait for the thread that started this one to finish initializing the
+ // thread handle so that getThreadId/getThreadHandle will work.
+ thr->m_start_finished_mutex.lock();
+
thr->m_retval = thr->run();
thr->m_running = false;