IThread.hpp

Go to the documentation of this file.
00001 #ifndef __IThread__
00002 #define __IThread__
00003 
00004 #include "../Basics/CCountedObject.hpp"
00005 #include "IThreadListener.hpp"
00006 #include "CCriticalSection.hpp"
00007 using Exponent::Threading::CCriticalSection;
00008 using Exponent::Threading::IThreadListener;
00009 using Exponent::Basics::CCountedObject;
00010 
00011 #ifndef WIN32
00012 #include <pthread.h>
00013 #endif
00014 
00015 //  ===========================================================================
00016 
00017 namespace Exponent
00018 {
00019     namespace Threading
00020     {
00038         interface IThread
00039         {
00040         public:
00041 
00042 //  ===========================================================================
00043 
00048             enum EThreadPriority
00049             {
00050                 e_highPriority = 0,         
00051                 e_normalPriority,           
00052                 e_lowPriority,              
00053             };
00054 
00055 //  ===========================================================================
00056 
00061             struct SThreadHandle
00062             {
00063                 #ifdef WIN32
00064                     HANDLE m_threadHandle;              
00065                 #else
00066                     pthread_t *m_threadHandle;          
00067                 #endif
00068             };
00069             
00070 //  ===========================================================================
00071             
00075             IThread() { }
00076             
00080             virtual ~IThread() { }
00081             
00082 //  ===========================================================================
00083             
00088             virtual bool runThread() = 0;
00089 
00094             virtual void stopThread() = 0;
00095 
00100             virtual bool isThreadActive() const = 0;
00101 
00102 //  ===========================================================================
00103               
00108             virtual void registerThreadListener(IThreadListener *listener) = 0;
00109 
00114             virtual IThreadListener *getThreadListener() = 0;
00115 
00116 //  ===========================================================================
00117 
00122             virtual void setThreadPriority(const IThread::EThreadPriority priority) = 0;
00123 
00128             virtual IThread::EThreadPriority getThreadPriority() const = 0;
00129 
00130 //  ===========================================================================
00131 
00136             virtual void sleepThread(const long timeInMilliseconds) = 0;
00137 
00138 //  ===========================================================================
00139 
00144             virtual void setThreadHandle(IThread::SThreadHandle *threadHandle) = 0;
00145 
00150             virtual IThread::SThreadHandle *getThreadHandle() = 0;
00151 
00152 //  ===========================================================================
00153 
00158             virtual void setCriticalSection(CCriticalSection *criticalSection) = 0;
00159         };
00160     }
00161 }
00162 #endif  // End of IThread.hpp

Infinity API - IThread.hpp Source File generated on 7 Mar 2007