From 33fc1474d90ea68df862e5a5c15980a11961bf16 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 22 Jun 2015 21:27:13 +0100 Subject: Fixed minor errors in Tycho's code Everything should work now :) --- src/OSSupport/IsThread.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/OSSupport/IsThread.h') diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h index f642c8724..fa6813cd7 100644 --- a/src/OSSupport/IsThread.h +++ b/src/OSSupport/IsThread.h @@ -32,10 +32,6 @@ protected: /** The overriden Execute() method should check this value periodically and terminate if this is true. */ volatile bool m_ShouldTerminate; -private: - /** Wrapper for Execute() that waits for the initialization event, to prevent race conditions in thread initialization. */ - void DoExecute(void); - public: cIsThread(const AString & a_ThreadName); virtual ~cIsThread(); @@ -51,14 +47,21 @@ public: /** Returns true if the thread calling this function is the thread contained within this object. */ bool IsCurrentThread(void) const { return std::this_thread::get_id() == m_Thread.get_id(); } + +private: -protected: + /** The name of the thread, used to aid debugging in IDEs which support named threads */ AString m_ThreadName; + + /** The thread object which holds the created thread for later manipulation */ std::thread m_Thread; /** The event that is used to wait with the thread's execution until the thread object is fully initialized. - This prevents the IsCurrentThread() call to fail because of a race-condition. */ + This prevents the IsCurrentThread() call to fail because of a race-condition where the thread starts before m_Thread has been fully assigned. */ cEvent m_evtStart; + + /** Wrapper for Execute() that waits for the initialization event, to prevent race conditions in thread initialization. */ + void DoExecute(void); } ; -- cgit v1.2.3