diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-06-22 22:27:13 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-06-22 22:27:13 +0200 |
commit | 33fc1474d90ea68df862e5a5c15980a11961bf16 (patch) | |
tree | 0db0968d8078cc0fc1fbd164f080f9e0d32f553e /src/OSSupport/IsThread.h | |
parent | Reinstate "Chunk queue collapsing" (diff) | |
download | cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.gz cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.bz2 cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.lz cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.xz cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.zst cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.zip |
Diffstat (limited to '')
-rw-r--r-- | src/OSSupport/IsThread.h | 15 |
1 files changed, 9 insertions, 6 deletions
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); } ; |