From cde195c1569f22027306adf12e0e3e520d69b9f8 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 27 Aug 2014 12:29:57 +0300 Subject: AnvilStats: Fixed thread start race condition. The whole program would sometimes fail to process anything because the threads were waited-for before they were started. --- Tools/AnvilStats/Processor.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Tools/AnvilStats/Processor.h') diff --git a/Tools/AnvilStats/Processor.h b/Tools/AnvilStats/Processor.h index 72fea3081..db50ec619 100644 --- a/Tools/AnvilStats/Processor.h +++ b/Tools/AnvilStats/Processor.h @@ -30,6 +30,7 @@ class cProcessor cCallback & m_Callback; cProcessor & m_ParentProcessor; + cEvent m_HasStarted; // cIsThread override: virtual void Execute(void) override; @@ -48,6 +49,9 @@ class cProcessor public: cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor); + + /** Waits until the thread starts processing the callback code. */ + void WaitForStart(void); } ; typedef std::vector cThreads; @@ -65,10 +69,12 @@ protected: AStringList m_FileQueue; cThreads m_Threads; - cEvent m_ThreadsHaveStarted; // This is signalled by each thread to notify the parent thread that it can start waiting for those threads - + + + /** Populates m_FileQueue with Anvil files from the specified folder. */ void PopulateFileQueue(const AString & a_WorldFolder); + /** Returns one filename from m_FileQueue, and removes the name from the queue. */ AString GetOneFileName(void); } ; -- cgit v1.2.3