summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/IsThread.h
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-07-04 15:43:00 +0200
committerworktycho <work.tycho@gmail.com>2015-07-04 15:43:00 +0200
commit106e06617afea6e07e99c7674b2d10ece96b1344 (patch)
treebc1237dd50c603f1f5e806574d8496f4f361b29c /src/OSSupport/IsThread.h
parentMerge pull request #2312 from SamJBarney/master (diff)
parentFixed minor errors in Tycho's code (diff)
downloadcuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar
cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.gz
cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.bz2
cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.lz
cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.xz
cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.zst
cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.zip
Diffstat (limited to 'src/OSSupport/IsThread.h')
-rw-r--r--src/OSSupport/IsThread.h15
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);
} ;