CIteratorThread::CIteratorThread() { write_log(preferences.debug_prwin(), "[PrWinThread] Iterator Thread starting.\n"); // Create events _m_stop_thread = CreateEvent(0, TRUE, FALSE, 0); _m_wait_thread = CreateEvent(0, TRUE, FALSE, 0); // Initialize variables InitHandranktTableForPrwin(); AfxBeginThread(IteratorThreadFunction, this); write_log(preferences.debug_prwin(), "[PrWinThread] Iterator Thread started.\n"); }
CIteratorThread::CIteratorThread() { write_log(preferences.debug_prwin(), "[PrWinThread] Iterator Thread starting.\n"); // Create events _m_stop_thread = CreateEvent(0, TRUE, FALSE, 0); _m_wait_thread = CreateEvent(0, TRUE, FALSE, 0); // Initialize variables InitIteratorLoop(); InitHandranktTableForPrwin(); // FIRST mark thread as running, // THEN start thread. // The other way can lead to an ugly race-condition, // if the thread has already stopped, when we mark it as running. iter_vars.set_iterator_thread_running(true); AfxBeginThread(IteratorThreadFunction, this); write_log(preferences.debug_prwin(), "[PrWinThread] Iterator Thread started.\n"); }