00001 #ifndef __CCriticalSection__ 00002 #define __CCriticalSection__ 00003 00004 #include "../Basics/CCountedObject.hpp" 00005 using Exponent::Basics::CCountedObject; 00006 00007 // =========================================================================== 00008 00009 namespace Exponent 00010 { 00011 namespace Threading 00012 { 00030 class CCriticalSection : public CCountedObject 00031 { 00033 EXPONENT_CLASS_DECLARATION; 00036 // =========================================================================== 00037 00038 public: 00039 00040 // =========================================================================== 00041 00045 CCriticalSection(); 00046 00050 virtual ~CCriticalSection(); 00051 00052 // =========================================================================== 00053 00059 bool tryToEnterCriticalSection(const long spinTimeInMilliseconds) const; 00060 00064 void enterCriticalSection(void) const; 00065 00069 void leaveCriticalSection(void) const; 00070 00071 // =========================================================================== 00072 00073 protected: 00074 00075 // =========================================================================== 00076 00077 #ifdef WIN32 00078 CRITICAL_SECTION *m_criticalSection; 00079 #else 00080 MPCriticalRegionID m_criticalSection; 00081 #endif 00082 }; 00083 } 00084 } 00085 00086 #endif