+
+ /** This is called by the default destructor of the Thread
+ * class to ensure that the thread engine which created the thread
+ * is responsible for destroying it.
+ */
+ virtual void FreeThread(Thread* thread) = 0;
+
+ virtual const std::string GetName()
+ {
+ return "<pure-virtual>";
+ }
+};
+
+/** Derive from this class to implement your own threaded sections of
+ * code.
+ */
+class CoreExport Thread : public Extensible
+{
+ private:
+ bool ExitFlag;
+ public:
+
+ /** Creator thread engine
+ */
+ ThreadEngine* Creator;
+
+ /** Set Creator to NULL at this point
+ */
+ Thread() : ExitFlag(false), Creator(NULL)
+ {
+ }
+
+ /** If this thread has a Creator set, call it to
+ * free the thread
+ */
+ virtual ~Thread()
+ {
+ if (Creator)
+ Creator->FreeThread(this);
+ }
+
+ /** Override this method to put your actual
+ * threaded code here
+ */
+ virtual void Run() = 0;
+
+ void SetExitFlag()
+ {
+ ExitFlag = true;
+ }
+
+ void ClearExitFlag()
+ {
+ ExitFlag = false;
+ }
+
+ bool GetExitFlag()
+ {
+ return ExitFlag;
+ }